﻿///<jscompress sourcefile="Base.js" />
Yacon = {
  
	//浏览器地址判断方法	
    regCheck: function (reg)
    {
        return reg.test(window.uag);
    },
    
    apply:function(obj, org, defaults)
    {
       	if(defaults){
       		Yacon.apply(obj, defaults);
        }  
    	
        if(obj && org && typeof org == 'object'){
            for(var p in org){
            	
                if (Yacon.isObject(obj))
                	obj[p] = org[p];
                else
                	obj.prototype[p] = org[p];
            }
        }
        return obj;
    },
    
	Extend:function(self,par,arg)
	{    	
       	if (!par)
   		  par = Object;    	 
    	  	  
    	  var parObj = new par();
    	  self.prototype = parObj;
    	  self.prototype.constructor = self; 
    	  self.prototype.superclass = parObj;
    	  
		  if(par.constructor == Object.prototype.constructor) 
		  {
			  par.prototype.constructor = par;
		  }
		 
		 if(typeof arg == 'object'){
			 for(var p in arg)
			 {
				 self.prototype[p]=arg[p];
        	 } 
        } 
		
    	return self;
	},
	
    fireUserEvent :function (function_name,param)
    {
    	var result;
        var paramstr="";
        
        if (arguments.length == 2)
    	{
    		for(var i=0; i<param.length; i++)
    		{
    			if (i==0)
    			{	
    				paramstr="param["+i+"]";
                }else
    			{
    				paramstr=paramstr+",param["+i+"]";
    			}
            }
       }
        if (this.isfireuserEvent(function_name)){
         	eval("result="+function_name+"("+paramstr+");");
         }
      
         return result;
    },
   
    isfireuserEvent :function (function_name)
    {	
    	var result = false;
    	
    	if (this.isEmpty(function_name))
    		return result;
    	
    	eval("result=(typeof("+function_name+")!=\"undefined\");");
    
        return result;
    },
    
    /* 截取字符串px */
    getPx:function(value){
    	if(this.isDefined(value)){
    		return -1;
    	}
    	return this.getInt(value.substring(0,value.length-2));
    },
    
    getInt:function (value)
    {
    	if (this.isDefined(value))
			return -1;
    	
    	var result = parseInt(value);
    	if (isNaN(result)){ result = -1;}
    	return result;
    },
    
    getFloat:function(value)
    {
    	if (this.isDefined(value))
			return -1;
    	
    	var result = parseFloat(value);
		if (isNaN(result)){ result = -1;}
		return result;
	},
	
	isTrue:function (value)
	{
		if (this.isEmpty(value))
			return false;
		if(this.isBoolean(value))
			return value;
		if (this.isString(value))
		{
			return (value.isEqual("1") ||
				value.toLowerCase().isEqual("true") || value.isEqual("T") ||
				value.toLowerCase().isEqual("yes") || value.toLowerCase().isEqual("on"));
		}
	},
	
    isEmpty : function(obj){
        return obj === null || obj === undefined|| ((Yacon.isString(obj) && !obj.length)) || ((Yacon.isArray(obj) && !obj.length));
    },

    isArray : function(obj){
        return Object.prototype.toString.apply(obj) === '[object Array]';
    },

    isDate : function(obj){
        return Object.prototype.toString.apply(obj) === '[object Date]';
    },

    isObject : function(obj){
    	if (!this.isDefined(obj))
    		return Object.prototype.toString.call(obj) === '[object Object]' ||typeof (obj) == "object";
    	else
    		return false;
    },

    isFunction : function(obj){
        return Object.prototype.toString.apply(obj) === '[object Function]';
    },

    isNumber : function(obj){
        return typeof obj === 'number';
    },    
    isString : function(obj){
        return typeof obj === 'string';
    },

    isBoolean : function(obj){
        return typeof obj === 'boolean';
    },

    isElement : function(obj) {
        return obj ? !!obj.tagName : false;
    },

    isDefined : function(obj){    	
        return typeof obj == 'undefined';
    },
    
    isNull:function(obj){
    	return !obj && typeof obj != "undefined" && obj != 0;
    },
    
    /* 获取页面地址路径 */
    getRootPath:function(){
        //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
        var curWwwPath=window.document.location.href;
        //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
        var pathName=window.document.location.pathname;
        var pos=curWwwPath.indexOf(pathName);
        //获取主机地址，如： http://localhost:8083
        var localhostPaht=curWwwPath.substring(0,pos);
        //获取带"/"的项目名，如：/uimcardprj
        var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
        return(localhostPaht+projectName);
    },
    
    /* 获取页面相对地址 */
    getRelaPath:function(){
    	var pathName=window.document.location.pathname;
    	return pathName.substr(pathName.substr(1).indexOf('/')+1);
    },

    /* HTTP/HTTPS校验 */
    verifySSL : function(){
    	var rootPath = window.document.location.href;
    	var path = rootPath.indexOf("https://");
    	if(path<0){
    		return false;
    	}else{
    		return true;
    	}
    },
    
    /* 防止普通注入 */   
    stripDefend:function(s){
    	var pattern = new RegExp("[%`~!@#$^&*()=|{}';',\\[\\]<>?~！@#￥……&*（）――|{}【】‘；：”“'。，、？]") ;//格式 RegExp("[在中间定义特殊过滤字符]")
		var rs = "";
		if(s.length > 0){
			for (var i = 0; i < s.length; i++) {
				rs = rs + s.substr(i, 1).replace(pattern, '');
			}
		}
		return rs;
    },
    
    /* 防止SQL注入 */
    stripSQL:function(oField){
    	 var re= /select|update|having|delete|exec|count|’|"|=|;|>|<|%/i;
         if ( re.test(oField) )
         {
           alert("请您不要在参数中输入特殊字符和SQL关键字！");
       	  location.href="";
    		 } 
         return oField;
    },
    
    getUrlParam: function(name,url) {
        
        var actUrl = "";
        if(url){
     	   actUrl = url;
        }
        else{
     	   actUrl = location.search;
        }
        
 	   var theRequest = new Object();
 	   if (actUrl.indexOf("?") != -1) {
 	      var str = actUrl.substr(1);
 	      strs = str.split("&");
 	      for(var i = 0; i < strs.length; i ++) {
 	         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
 	      }
 	   }
 	   return theRequest[name];
     },
     
     /* 弹窗 */
     showModal:function(element){
    	 
    	 /* 前置方法 */
    	 Yacon.callBackMethod(element.before);
    	 
    	 /* 存在dataSet */
    	 if(element.dataSet){
    		 
    		 element.dataSet.switchWindow(element);
    		 
    		 var showWindow = new Yacon.widget.TWindow(element);
    		 
    		 showWindow.dataSet = element.dataSet;
    		 
    		 if(!Yacon.isEmpty(element.close)){
    			 showWindow.close = element.close;
    		 }
    		 
    		 showWindow.show();
    		 
    	 }
    	 
    	 /* 不存在dataSet */
    	 else{
    		 
    		 var dataSet = new Yacon.data.DataSet(window.page);
    		 
    		 Yacon.def.window_idx++;
    		 
    		 dataSet.elementID = "default_window"+Yacon.def.window_idx; 		  
    		 dataSet.switchWindow(element);
    		 
    		 var showWindow = new Yacon.widget.TWindow(element);
    		 showWindow.dataSet = dataSet;
    		 showWindow.page = window.page;
    		 
    		 if(!Yacon.isEmpty(element.close)){
    			 showWindow.close = element.close;
    		 }
    		 
    		 /* 页面展示 */
    		 showWindow.show(); 
    		 
    	 }
    	 
    	 /* 后续方法 */
    	 Yacon.callBackMethod(element.before);
    	 
     },
     
     addUrlParam: function(paramName,paramValue,url){
    	 
    	 if(url == undefined){
    		 url = window.location.href;
    	 }
    	 
    	 if(paramValue == undefined){
    		 return url;
    	 }
    	 
    	 if(url.indexOf("?")<0){
    		 url += "?"+paramName+"="+paramValue;
 		}else{
 			 url += "&"+paramName+"="+paramValue;
 		}
    	 
    	 return url;
    	 
     },
     
     /* 固定回调 */
     callBackMethod: function(element){
    	 if(!Yacon.isEmpty(element)){
    		 
    		 if(Yacon.isString(element)){
    			 Yacon.callBack(element, []);
    		 }
    		 
    		 else if(Yacon.isObject(element)){
    			 
        		 var method = element.method;
        		 var param = element.param;
        		 
        		 if(Yacon.isEmpty(method)){
        			 return;
        		 }
        		 
        		 if(Yacon.isEmpty(param)){
        			 param = [];
        		 }
        		 
        		 Yacon.callBack(method, param);
        		 
    		 }
    		 
    	 }
    	
     },
     
     /* 自定义回调 */
     callBack: function(methodName, methodParam){
    	 
    	 if(Yacon.isEmpty(methodParam)){
    		 param = [];
    	 }
    	 
    	 if(Yacon.isfireuserEvent(methodName)){    		 
    		 return Yacon.fireUserEvent(methodName, methodParam); 
    	 }
    	 
     },
     
     find: function(elementID,fieldName){
    	 
    	 if(Yacon.isEmpty(fieldName)){
    		 var active = $("#"+elementID);    	 
        	 var role = active.attr("lily-player");
        	 
        	 if(role == "tsqlgrid"){    		 
        		 var tsqlgrid = new Yacon.component.TSqlGrid({element:active});   
        		 tsqlgrid.getDataSet();
        		 return tsqlgrid;    		 
        	 }
        	 
        	 else if(role == "twindow"){
        		 return getWindow(elementID);
        	 }
    	 }
    	 
    	 else{
    		 
    		 if(!Yacon.isEmpty(elementID)){
    			 return $("#"+elementID+" .lily-field[field-name='"+fieldName+"']"); 
    		 }else{
    			 return $(".lily-field[field-name='"+fieldName+"']"); 
    		 }
    		    		 
    	 }
    	  
     },
     
	 getWidthNumber: function(widthStr){
		 
		widthStr = widthStr + "";
		
		widthStr = widthStr.trim();
		
		if(widthStr.endWith("px")){
			return parseInt(widthStr.substring(0,widthStr.length-2));
		}
		
		else if(widthStr.endWith("%")){			
			var num = parseInt(widthStr.substring(0,widthStr.length-1)) / 100;		
			return $(window).width() * num;
		}
		
		else{			
			return parseInt(widthStr);		
		}
		
	 },
     
     /* 获取地址参数信息 */
     findParam: function(paramName,url){
    	 return Yacon.getUrlParam(paramName, url);
     },
     
     upload: function(fileID,callBack){
    	 
    	 var setting = {
    		 url: page.element.contextPath+"/UI/portalbs/tools/file/fileUpload.jsp?fileID="+fileID,
    		 width: "600px",
    		 heigth: "100px"
    	 }
    	 
    	 if(!Yacon.isEmpty(callBack)){
    		 setting.close = callBack;
    	 }
    	 
    	 Yacon.showModal(setting);
     },
     
     download: function(filePath){
		 var test=window.open(filePath); 
		 test.document.execCommand("SaveAs");   
		 window.close(); 
		 test.close();    	 
     },
     
     sleep: function (numberMillis) {
	    var now = new Date();
	    var exitTime = now.getTime() + numberMillis;
	    while (true) {
	        now = new Date();
	        if (now.getTime() > exitTime)
	            return;
	    }
	 }
    
};

Yacon.util = {};
Yacon.data = {};
Yacon.view = {};
Yacon.container = {};
Yacon.widget = {};
Yacon.component = {};
Yacon.dispatch = {};
Yacon.dispatch.msg = {};

/**
 * 初始构造函数
 */
(function(){  
	      
	window.uag = navigator.userAgent.toLowerCase();
    window.docMode = document.documentMode;
    window.isStrict = document.compatMode == "CSS1Compat";
    window.isfirefox = Yacon.regCheck(/firefox/);
    window.isOpera = Yacon.regCheck(/opera/);
    window.isChrome = Yacon.regCheck(/\bchrome\b/);
    window.isWebKit = Yacon.regCheck(/webkit/);
    window.isSafari = !isChrome && Yacon.regCheck(/safari/);
    window.isSafari2 = isSafari && Yacon.regCheck(/applewebkit\/4/);
    window.isSafari3 = isSafari && Yacon.regCheck(/version\/3/);
    window.isSafari4 = isSafari && Yacon.regCheck(/version\/4/);
    window.isIE11 = uag.indexOf("trident") > -1 && uag.indexOf("rv") > -1;
    window.isIE = Yacon.regCheck(/msie/);    
    window.isIE10 = isIE && (Yacon.regCheck(/msie 10/));
    window.isIE9 = isIE && (Yacon.regCheck(/msie 9/));
    window.isIE7 = isIE && (Yacon.regCheck(/msie 7/) || docMode == 7);
    window.isIE8 = isIE && (Yacon.regCheck(/msie 8/) && docMode != 7);
    window.isIE6 = isIE && (Yacon.regCheck(/msie 6/) && docMode != 7);
    window.isGecko = !isWebKit && Yacon.regCheck(/gecko/);
    window.isGecko2 = isGecko && Yacon.regCheck(/rv:1\.8/);
    window.isGecko3 = isGecko && Yacon.regCheck(/rv:1\.9/);
    window.isBorderBox = isIE && !isStrict;
    window.isWindows = Yacon.regCheck(/windows|win32/);
    window.isMac = Yacon.regCheck(/macintosh|mac os x/);
    window.isAir = Yacon.regCheck(/adobeair/);
    window.isLinux = Yacon.regCheck(/linux/);
    window.isSecure = /^https/i.test(window.location.protocol);
  
    if(window.isIE6){
        try{
        	document.execCommand("BackgroundImageCache", false, true);
        }catch(e){}
    }
    window.constErrUnknown = "程序引起未知错误！";
        
})();

Yacon.def =
{
	window_ico : "glyphicon glyphicon-user",	
	window_idx : 1
};

/* 文件上传 */
function upLoadFile(fileID)
{
	var dialogArg = "dialogwidth:600px; Dialogheight:100px;center:yes;help:no;resizable:no;scroll:no;status:no";
	var arg = new Object();			
	var dd  = window.showModalDialog(page.element.contextPath+"/UI/portal/fileupload/fileupload.jsp?fileID="+fileID,arg, dialogArg);
}
;
///<jscompress sourcefile="Array.js" />
Array = Yacon.apply(Array,{
	
	
	max:function()
	{
	   	var i, maxval = this[0];
	   	for (i = 1; i < this.length; i++)
	   	{
	   		if (maxval < this[i])
	   			maxval = this[i];
	   	}
	   return maxval;
	},
	
	min:function()
	{
	   	var i, minval = this[0];
	   	for (i = 1; i < this.length; i++)
	   	{
	   		if (minval > this[i])
	   			minval = this[i];
	   	}
	   return minval;
	},
	
	replace:function (array)
	{
	    this.clear();
	    for(var i in array)
    	{
	    	this[i] = array[i];
    	} 
	    return this;
	   
	},

	add:function (obj)
	{	    
	    this[this.length] = obj;
	    return this;
	 },
	
	get:function (index)
	 {
	     if ((index < this.length) && (index >= 0))
	 	 {
	         return this[index];
	     }
	     return null;
	 },
	
	 indexOf:function (obj)
	 {
	     for (var i = 0; i < this.length; i++)
	 	 {
	         if (this[i] == obj)
	 		 {
	             return i;
	         }
	     }
	     return -1;
	 },
	
	 isExit:function (obj)
	 {
	     for (var i = 0; i < this.length; i++)
	 	 {
	         if (this[i] == obj)
	 		 {
	             return true;
	         }
	     }
	     return false;
	 },
	
	 remove:function (obj)
	 {
		
		 if (Yacon.isNumber(obj))
    	 {
    		 if (obj < 0 ||obj >= this.length)
    			 return this;
    	 }
		 
		 var tempList = new Array();
	     for (var i = 0, ti = 0; i < this.length; i++)
	 	 {
	    	 if (Yacon.isNumber(obj))
	    	 {
	    		 if (i != obj)
		 		 {
		             tempList[ti] = this[i];
		             ti++;
		         }else
		         {
		        	delete this[i];
		         }
	    	 }else
	    	 {
		    	 if (this[i] != obj)
		 		 {
		             tempList[ti] = this[i];
		             ti++;
		         }else
		         {
		        	 delete this[i];
		         }
	    	 }
	     }
	     this.replace(tempList);
	     return  this;
	 },

	size:function ()
	{
	    return this.length;
	},

	clear:function ()
	{
	    for (var i= this.length-1;i>-1;i--)
		{
	        this[i] = null;
			delete this[i];
	    }
	    this.length = 0;
	}

});
	





;
///<jscompress sourcefile="Function.js" />
Function =Yacon.apply(Function,{	
		
	 	createInterceptor : function(fcn)
	 	{		  
			if(typeof fcn != "function"){
		        return this;
		    }				
		    var method = this;
		    return function() {		    	
		        if(fcn.apply(this || window, arguments) === false){
		            return;
		        }
		        return method.apply(this || window, arguments);
		    };
		},
		
	    createCallback : function()
	    {
	        var args = arguments,
	        method = this;
	        return function() {
	            return method.apply(window, args);
	        };
	    },
	   
	    Extend :function (par,arg){ 
	    	Yacon.Extend(this,par,arg);    
	    }
});




;
///<jscompress sourcefile="String.js" />
String =Yacon.apply(String,{	
	
	
	valid:function (str) 
	{
		var str= str+"";
		if (str=="undefined" || str=="null")
		{
			return "";
		}else
		{
			return str;
		}
	},
	
	contains :function (subStr) 
	{
	    return (this.indexOf(subStr) > -1);
	},

	startsWith:function (subStr) 
	{
	    return (this.substr(0, subStr.length) ==subStr);
	},
	
	endWith:function(subStr){
		return (this.substr(this.length-subStr.length, subStr.length) ==subStr);
	},
	
	search:function(){
		var idx = this.indexOf("?");
		var len = this.length - idx;
		return (this.substr(idx,len));
	},

	trim:function () 
	{	
	    return this.replace(/(^\s*)|(\s*$)/g, "");
	},

	ltrim :function () 
	{
	    return this.replace(/^\s*/g, "");
	},

	rtrim :function () 
	{
	    return this.replace(/\s*$/g, "");
	},

	replaceNewLineChars :function (subStr)
	{
	    return this.replace(/\n/g, subStr);
	},
	
	getReplace:function(reStr,plStr)
	{
		reStr = reStr/g;
		return this.replace(reStr, plStr);
	},

	isTrue:function ()
	{
		return (this==true ||this.isEqual("1") ||
			this.isEqual("true") || this.isEqual("T") ||
			this.isEqual("yes") || this.isEqual("on"));
	},
	
	getInt:function()
	{
		var result = parseInt(this);
		if (isNaN(result)){ result = 0;}
		return result;
	},
	
	getFloat:function()
	{
		var result = parseFloat(this);
		if (isNaN(result)){ result = 0;}
		return result;
	},

	isEqual:function(str)
	{
		str = this.valid(str);
		if (this==str){return true;}
		if (this=="" || str==""){ return false;}		
		return (str.toLowerCase()==this.toLowerCase());
	},
	
	getCLength:function()
	{
		 var ascRegexp = /[^\x00-\xFF]/g;
		 return this.replace(ascRegexp, '...').length;	 
	},
	
	subCStr :function(start, length)
	{
		if (length<=0)
			 return this;
		
		var strLen =0;
		var ascRegexp = /[^\x00-\xFF]/g;
		var retStr="";
		for (var i=start;i<this.length;i++)
		{
			if( this.charAt(i).match(ascRegexp))
				strLen = strLen + 3;
			else
				strLen ++;
			
			if (strLen <= length)
				retStr = retStr +this.charAt(i);
			else
				return retStr;				
		}
		
		return retStr;
		
	 },
	
	fillLZero:function(Length)
	{
		var tmp = this ; 
		for (var i= this.length;i<Length;i++){
			tmp = "0" + tmp ;
		}
		return tmp;
	},
	
	encode:function()
	{
		var intLen  = this.length;
		var strOut  ="";
		var strTemp ="";
		var strFlag = "";

		for(var i=0;i<intLen;i++)
		{
			strTemp = this.charCodeAt(i);

			if (strTemp > 255 || strTemp < 0)
			{
				if (strFlag == "")
				{
					strFlag = "^";
					strOut  = strOut+"[^" + strTemp.toString(16).fillLZero(4);
				}
				else if (strFlag == "~")
				{
					strFlag = "^";
					strOut  = strOut + "^" + strTemp.toString(16).fillLZero(4);
				}
				else if (strFlag == "^")
				{
					strOut = strOut + strTemp.toString(16).fillLZero(4);
				}
			}
			else
			{
				if (strTemp < 48 || (strTemp > 57 && strTemp < 65) || (strTemp > 90 && strTemp < 97) || strTemp > 122)
				{
					if (strFlag == "")
					{
						strFlag = "~";
						strOut  = strOut + "[~" + strTemp.toString(16).fillLZero(2);
					}
					else if (strFlag == "^")
					{
						strFlag = "~";
						strOut  = strOut + "~" + strTemp.toString(16).fillLZero(2);
					}
					else if (strFlag == "~")
					{
						strOut = strOut + strTemp.toString(16).fillLZero(2);
					}
				}
				else
				{
					if (strFlag == "^" || strFlag == "~")
					{
						strFlag = "";
						strOut  = strOut + "]" + this.charAt(i);
					}
					else
					{
						strOut = strOut + this.charAt(i);
					}
				}
			}
		}
				
		return strOut ;
	},
	
	decode:function ()
	{
		var intLen  = this.length;
		var strFlag = "";
		var strOut  = "";
		var strTemp = "";
		
		for(var i=0;i<intLen;i++)
		{
			strTemp = this.charAt(i);

			if (strTemp == "[")
			{
				i++;
				strTemp = this.charAt(i);
			}
			if (strTemp == "]")
			{
				strFlag = "";
				continue;
			}
			if (strTemp == "~")
			{
				i++;
				strFlag="~";
			}
			if (strTemp=="^")
			{
				i++;
				strFlag="^";
			}
			switch (strFlag)
			{
				case "~":
				{
					strTemp = this.substring(i,i+2);
					strTemp = parseInt(strTemp,16);
					strTemp = String.fromCharCode(strTemp);
					strOut  = strOut + strTemp;
					i++;
					break;
				}
				case "^":
				{
					strTemp = this.substring(i,i+4);
					if (strTemp.toUpperCase() == "FFFF"){
						i+=4;
						strTemp = this.substring(i,i+4);
					}
					strTemp = parseInt(strTemp,16);
					strTemp = String.fromCharCode(strTemp);
					strOut  = strOut + strTemp;
					i+=3;
					break;
				}
				case "":
				{
					strOut = strOut + strTemp;
					break;
				}
			}
		}
		
		return strOut;
	}
});




;
///<jscompress sourcefile="Page.js" />
Yacon.Page = function(element){
	
	this.element = element;	
	
	/* 布局参数处理 */
	this.element.width = Yacon.getWidthNumber($(window).width());
	this.element.height = document.body.clientHeight - 60;
	this.element.search = "";
	
	/* 当前页面中组件 */
	this.component = new Array();
	this.componentIdx = new Array();
	
};

Yacon.Page.prototype = {
	
	/* 信息展示 */	
	show : function(){
		
		var html = this.getHtml();	
		var self = this;
		
		$(".container-fluid.content").append(html);
		
		$(function(){
			for(var i=0;i<self.component.length;i++){			
				Yacon.callBack(self.component[i].elementID+"_load", [self.component[i],self]);			
			}
		});
		
	},
	
	/* 获取Html信息 */
	getHtml: function(){
		
		if(this.element.layout){
			
			if(!Yacon.isEmpty(this.windows)){
				
				this.windowId = this.windows.elementID;		
				
				this.element.width = Yacon.getWidthNumber(this.windows.element.width+"");
				this.element.height = Yacon.getWidthNumber(this.windows.element.height+"");
				this.element.search = "#"+this.windowId;
				
			}
			
			this.view = new Yacon.LayoutView(this.element.layout);
			
			this.view.page = this;
			
			return this.view.getLayoutHtml();
		}
		
		return "";
	},
	
	/* 添加组件 */
	addComponet : function(component){		
		this.component.add(component);
		this.componentIdx.add(component.elementID);
		eval("this."+component.elementID+" = component;");
	},
	
	/* 获取组件 */
	find : function(componentID){
		var idx = this.componentIdx.indexOf(componentID);
		return this.component.get(idx);
	},
	
	/* 绑定动作 */
	addEvents: function(componentID){
		
		if(!Yacon.isEmpty(componentID)){
			var activeElement = this.find(componentID);
			activeElement.addEvents();
		}
		else{
			for(var i=0;i<this.component.length;i++){
				var activeElement = this.component[i];
				activeElement.addEvents();
			}
			
		}	
	},
	
	/* 布局 */
	layout: function(){	
		
		for(var i=0;i<this.component.length;i++){
			var activeElement = this.component[i];
			activeElement.layoutBefore();
		}
		
		var layout = new Yacon.Layout();		
		this.layoutInner(this.element.height,this.element.search);
		this.layoutOuter(this.element.search);	
		
	},
	
	/* 外部布局 */
	layoutInner: function(height,parent){
		var layout = new Yacon.Layout();
		layout.layoutInner(height,parent);
	},
	
	/* 内部布局 */
	layoutOuter: function(parent){
		var layout = new Yacon.Layout();
		layout.layout(parent);
	}
		
};;
///<jscompress sourcefile="Layout.js" />
Yacon.Layout = function(){	
	this.winHeight = document.body.clientHeight;
	this.docHeigtht = $(document).height();
	
	this.innerHeight = this.winHeight - 60;
	
};

Yacon.Layout.prototype = {
	
	/* 处理普通布局 */	
	layout:function(parent){
		
		var cols = $(".col");	
		
		if(!Yacon.isEmpty(parent)){
			cols = $(parent+" .col");
		}
		
		var col_length = cols.length;
		
		for(var i=0;i<col_length;i++){
			
			var parent = cols.eq(i);
			
			this.layoutChild(parent);
			
		}
		
	},
	
	/* 内部布局 - 子节点 */
	layoutChild:function(parent){
		
		var totalHeight = parent.height();
		var resultHeight = totalHeight;
		
		var childs = parent.children("div");
		
		var autosize = 0;
		var fixsize = 0;
		
		var autoDivs = new Array();
		
		//首次过滤
		for(var j=0;j<childs.length;j++){
			
			var flag = false;
			
			//固定高度
			if(childs.eq(j).hasClass("row-ht-fix")){
				resultHeight = resultHeight - childs.eq(j).outerHeight(true);
				fixsize++;	
				flag = true;
				continue;
			}
			
			//随机高度
			else if(childs.eq(j).hasClass("row-ht-auto")){				
				autoDivs.add(childs.eq(j));
				autosize++;
				flag = true;
				continue;
			}
			
			else if(childs.eq(j).hasClass("row-ht-all")){
				childs.eq(j).css("height","100%");
				flag = true;
				continue;
			}
			
			//分级高度
			for(var i=1;i<=12;i++){
				
				if(childs.eq(j).hasClass("row-ht-"+i)){				
					var height = totalHeight / 12 * i;
					childs.eq(j).css("height",height+"px");	
					resultHeight = resultHeight - height;
					flag = true;
					break;
				}
				
			}
			
			if(flag){
				continue;			
			}else{
				resultHeight = resultHeight - childs.eq(j).outerHeight(true);
				fixsize++;	
				continue;
			}
			
		}
		
		//二次过滤		
		var itemHeight = resultHeight/autosize;
		
		for(var j=0;j<childs.length;j++){
			if(childs.eq(j).hasClass("row-ht-auto")){				
				childs.eq(j).css("height",itemHeight+"px");	
				continue;
			}
		}
		
		
	},
	
	/* 处理window布局 */
	layoutWindow:function(){
		
		$(".row-ht-window").css("height",this.winHeight+"px");
		
		for(var i=1;i<=12;i++){			
			var height = this.winHeight / 12 * i;
			$(".row-ht-window-"+i).css("height",height+"px");			
		}
		
	},
	
	/* 处理Inner布局 */
	layoutInner:function(height,parent){
		
		if(!Yacon.isEmpty(height)){
			this.innerHeight = height;
		}
		
		this.parent = "";
		if(!Yacon.isEmpty(parent)){
			this.parent = parent;
		}
		
		$(this.parent+" .row-ht-inner").css("height",this.innerHeight+"px");
		
		for(var i=1;i<=12;i++){			
			var activeHeight = this.innerHeight / 12 * i;
			$(this.parent+".row-ht-inner-"+i).css("height",activeHeight+"px");			
		}
		
	}

};;
///<jscompress sourcefile="LayoutEvent.js" />
Yacon.LayoutEvent = function(element){
	if(element){
		this.element = element;
	}	
};

Yacon.LayoutEvent.prototype = {
	
	/* 加载所有事件 */	
	loadEvents: function(elementID){
		
		if(Yacon.isEmpty(elementID)){
			this.components = $("div[lily-container='window']");
		}else{
			this.components = $("#"+elementID+" div[lily-container='window']");
		}
		
		for(var i=0;i<this.components.length;i++){
			
			this.active = this.components.eq(i);
			
			this.loadComponentEvents(this.active);
			
		}
		
	},
	
	/* 装载组件事件 */
	loadComponentEvents: function(component){
		
		if(component.attr("lily-player") == "tsqlgrid"){
			
			eval("window."+component.attr("id")+"= new Yacon.component.TSqlGrid({elementID:'"+component.attr("id")+"'});");
			
		}
		
		if(component.attr("lily-player") == "tree"){
			
			eval("window."+component.attr("id")+"= new Yacon.component.TTree({elementID:'"+component.attr("id")+"'});");
			eval("window."+component.attr("id")+".loadEvent();")
			
		}
		
	}
		
};;
///<jscompress sourcefile="LayoutView.js" />
Yacon.LayoutView = function(element){
	this.element = element;
	
};

Yacon.LayoutView.prototype = {
	
	show : function(srcLocation) {
		
		var html =  this.getLayoutHtml();
		
		$(".container-fluid.content").append(html);
				
	},
	
	/* 获取展示HTML */
	getLayoutHtml: function(){
		
		this.width = this.page.element.width;
		
		var html = "";
		var rowSize = this.element.length;
		var rowNum = 12 / rowSize;
		for(var i=0;i<rowSize;i++){			
			html += this.getRowHtml(this.element[i],rowNum);		
		}
		
		return html;		
	},
	
	/* 获取行 HTML 信息 */
	getRowHtml: function(row,rowNum) {
		
		var html = "";
		var colSize = row.length;
		var colNum = 12 / colSize;
		
		html += "<div class='row row-ht-auto col' style='padding-top: 10px;'>";
		
		for(var i=0;i<colSize;i++){
			html += this.getColHtml(row[i],colNum,rowNum);
		}
		
		html += "<div class='clearfix visible-xs-block'></div>"
		
		html += "</div>";
		
		return html;
		
	},
	
	/* 获取列HTML 信息 */
	getColHtml: function(col,divNum,rowNum) {
		
		var html = "";
		
		if(!Yacon.isEmpty(this.width)){
			
			if(col.width){
				
				var className = "col-md-"+col.width+" ";
				
				if(col.offset){
					className += "col-md-offset-"+col.offset+" ";
				}
				
				if(Yacon.isEmpty(this.height)){
					html += "<div class='"+className+" row-ht-12 col'>";
				}
				else{
					html += "<div class='"+className+" col' style='height:"+this.height+"px'>";
				}
				
				var width = this.width * col.width / 12 ;
				col.width = width - 36;
			}else{
							
				if(Yacon.isEmpty(this.height)){				
					html += "<div class='col-md-"+divNum+" row-ht-12 col'>";			
				}
				else{
					html += "<div class='col-md-"+divNum+" col' style='height:"+this.height+"px'>";	
				}
				
				var width = this.width * divNum / 12 ;		
				col.width = width - 36;
			}
			
		}
			
		html += this.getComponentHtml(col);
		
		html += "</div>";
		
		return html;
	},
	
	/* 获取组件HTML 信息 */
	getComponentHtml: function(component,width){
		
		var html = "";	
		var activeElement = null;
		
		//类型判断
		if(component.type){
			
			if(component.type == "tsqlgrid"){				
				activeElement = new Yacon.component.TSqlGrid({view:component,page:this.page});				
			}
				
			else if(component.type == "tpanel"){			
				activeElement = new Yacon.widget.TPanel({view:component,page:this.page});			
			}
			
			else if(component.type == "tframe"){				
				activeElement = new Yacon.widget.TFrame({view:component,page:this.page});				
			}
			
			else if(component.type == "tree"){
				activeElement = new Yacon.component.TTree({view:component,page:this.page});
			}
			
			else if(component.type == "multigrid"){
				activeElement = new Yacon.component.TMultiGrid({view:component,page:this.page});
			}
			
			else if(component.type == "tab"){
				activeElement = new Yacon.widget.TTab({view:component,page:this.page});
			}
			
		}
		
		if(!Yacon.isEmpty(activeElement)){		
			html += activeElement.getHtml();		
			this.page.addComponet(activeElement);
		}
				
		return html;
		
	}

};

;
///<jscompress sourcefile="JsonBaseConverter.js" />
Yacon.dispatch.msg.TJsonBaseConverter = function(){
	
	this.reqMsg = null;
	this.rspMsg = null;
	
};

Yacon.dispatch.msg.TJsonBaseConverter.Extend(Object,{
	
	/* 打包字段 */
	compactField: function(field){
		
		var fieldName = field.getFieldName();
		var fieldValue = field.getFieldValue();
		
		var jsonValue = "";
		
		if(fieldValue == undefined){
			jsonValue = "";
		}
		
		else if(Yacon.isNull(fieldValue)){
			jsonValue = "";
		}
		
		else if(fieldValue instanceof Yacon.container.Record){
			jsonValue = this.compactRecord(fieldValue);
		}
		
		else if(fieldValue instanceof Yacon.container.Table){
			jsonValue = this.compactTable(fieldValue);
		}
		
		else if(fieldValue.constructor == String){
			jsonValue = "'"+fieldValue+"'";
		}
		
		else if(fieldValue.constructor == Number){
			jsonValue = fieldValue;
		}
		
		else if(fieldValue instanceof Array){			
			jsonValue = this.compactArray(fieldValue);		
		}
		
		return "'"+fieldName+"'"+":"+jsonValue;
	},

	/* 打包表格 */
	compactTable: function(table){
		
		var jsonValue = "[";
		
		table.beforeFirst();	
		
		while(table.next()){
			
			var active = this.compactRecord(table.getRecord());
			
			jsonValue += active + ",";
			
		}
		
		if(table.getRecordCount() > 0){
			jsonValue = jsonValue.substring(0,jsonValue.length-1);
		}
			
		jsonValue += "]";
			
		return jsonValue;
	},
	
	/* 打包记录 */
	compactRecord: function(record){
		
		var jsonValue = "{";
		
		var fieldCount = record.getFieldCount();
		
		for(var i=0;i<fieldCount;i++){	
			jsonValue += this.compactField(record.getField(i)) + ",";			
		}
		
		if(fieldCount>0){
			jsonValue = jsonValue.substring(0,jsonValue.length-1);
		}
		
		jsonValue += "}";
		
		return jsonValue;
		
	},
	
	/* 打包数组 */
	compactArray: function(array){
		
		var jsonValue = "[";
		
		var size = array.length;
		
		for(var i=0;i<size;i++){
			
			var active = array[i];
			
			if(active instanceof Number){
				jsonValue += active +",";
			}
			
			else if(active instanceof String){
				jsonValue += "'"+active+"',";				
			}
			
		}
		
		if(jsonValue.length > 1){
			jsonValue = jsonValue.substring(0,jsonValue.length-1);
		}
		
		jsonValue += "]";
		
		return jsonValue;
	}
	
});;
///<jscompress sourcefile="XmlBaseConverter.js" />
;
///<jscompress sourcefile="Dispatch.js" />
Yacon.TDispatch = function(conText){
	
	this.req = null;
	this.rsp = null;
	
	Yacon.apply(this,conText);
	
	this.self = this;

};

Yacon.TDispatch.Extend(Object,{
	
	postPage : function(){
		
		var self = this.self;
		
		this.url = Yacon.addUrlParam("lilyPageType", "1", this.url);
		
		$.ajax({
            type: "POST",
            url: this.url,
            processData: false,
            async: false,
            dataType: 'text', 
            success: function(data){           	
            	self.rsp = data;  
            }
        });
		
	},
	
	post: function(isAsync) {
		
		var self = this.self;
		
		if(!isAsync){
			
			$.ajax({
	            type: "POST",
	            url: this.url,     
	            processData: false,
	            async: isAsync,
	            data: "switch_xml="+this.req,
	            dataType: 'text',             
	            success: function(data){           	
	            	//self.rsp = eval("("+data+")");  
	            	self.rsp = JSON.parse(data);
	            }
	        });
			
		}else{
			
			$.ajax({
	            type: "POST",
	            url: this.url,     
	            processData: false,
	            async: isAsync,
	            data: "switch_xml="+this.req,
	            dataType: 'text', 
	            beforeSend: function () {
	            	Yacon.callBackMethod(self.before);
                },
	            success: function(data){           	
	            	//self.rsp = eval("("+data+")");  
	            	self.rsp = JSON.parse(data);
	            	self.dataSet.rsp = self.rsp;
	            	Yacon.callBackMethod(self.after);
	            },
	            error: function (e, jqxhr, settings, exception) {
	            	Yacon.callBackMethod(self.after);
                }
	        });
			
		}
		

		
	}
	
});;
///<jscompress sourcefile="DataSet.js" />
Yacon.data.DataSet = function(page){
	
	this.dataset = new Yacon.container.Table();	
	this.body = new Yacon.container.Record();
	this.action = new Yacon.container.Record();
	this.record = null;	
	this.rsp = null;
	
	if(!Yacon.isEmpty(page)){
		this.page = page;
		this.baseCreate();
	}
			
};

Yacon.data.DataSet.Extend(Object,{
	
	/* 创建 */
	baseCreate: function(){
		
		if(Yacon.isEmpty(this.page)){
			
			return;
			
		}else{
				
			this.appCode = this.page.element.appCode;
			this.pagePath = this.page.element.pagePath;
			this.classPath = this.page.element.classPath;
			this.contextPath =  this.page.element.contextPath;	
			
			this.setAction("className",this.classPath);
			this.setAction("pagePath",this.pagePath);
			
			this.setAction("serviceCode","buss");
			this.setAction("traceID","111111");
			this.setAction("type","0");
			
			/* 页面地址信息 */
			if(!Yacon.isEmpty(this.page.element.parameter)){
				
				var params = this.page.element.parameter;
				
				for(var item in params){
					this.setBody(item,params[item]);
				}
				
			}
			
		}
		
	},
	
	/* 创建记录 */
	createRecord: function(){
		this.record = this.dataset.createRecord();
		return this.record;
	},
	
	/* 设置字段值 */
	setFieldValue: function(fieldName,fieldValue){
		
		if(this.record == null){
			this.getFirstRecord();
		}
		
		this.record.setFieldValue(fieldName,fieldValue);
	},
	
	/* 获取JSON信息 */
	getJSON: function(){
		
		var dataCompact = new Yacon.dispatch.msg.TJsonBaseConverter();
		
		var actionJS = dataCompact.compactRecord(this.action);
		var bodyJS = dataCompact.compactRecord(this.body);
		var datasetJS = dataCompact.compactTable(this.dataset);
		
		return "{action:"+actionJS+",body:"+bodyJS+",dataset:"+datasetJS+"}";
		
	},
	
	getFieldValue:function(fieldName){		
		return this.record.getFieldValue(fieldName);	
	},
	
	getFirstRecord:function() {
		this.record = this.dataset.getFirstRecord();
		
		if(this.record == undefined){
			this.record = this.createRecord();
		}
		
		return this.record;
	},
	
	setAction:function(attributeName,attributeValue){
		
		if(attributeValue == undefined){
			attributeValue = "";
		}
		
		this.action.setFieldValue(attributeName,attributeValue.encode());
	},
	
	getAction:function(attributeName){
		return this.action.getFieldValue(attributeName);
	},
	
	setBody:function(attributeName,attributeValue){
		
		if(attributeValue == null || attributeValue == undefined){
			attributeValue = "";
		}
		
		if(Yacon.isString(attributeValue)){
			this.body.setFieldValue(attributeName,attributeValue.encode());
		}else{
			this.body.setFieldValue(attributeName,attributeValue.toString().encode());
		}
		
		
	},
	
	getBody:function(attributeName){
		return this.body.getFieldValue(attributeName);
	},
	
	/* 前后台交互 */
	switchMessage: function(methodName) {
		
		if(methodName){
			this.setAction("methodName",methodName);
		}else{
			this.setAction("methodName",this.defaultMethod);
		}
			
		var dispatch = new Yacon.TDispatch({
			url:this.contextPath+"/managerService",
			req:this.getJSON()
		});
		
		dispatch.post(false);
		
		this.rsp = dispatch.rsp;
		
		/* 处理返回信息 */
		var typ = this.rsp.action.type;
		if(!Yacon.isEmpty(typ)){
			if(typ == "0" || typ == 0){
				alert(this.rsp.action.message);
			}
		}
		
		/* 存在返回表 */
		
		var rspData = this.rsp.dataset;
		if(!Yacon.isEmpty(rspData)){
			
			this.clearDataSet();
			
			for(var i=0;i<rspData.length;i++){	
				
				var rspRecord = rspData[i];	
				
				this.createRecord();
				
				for(var item in rspRecord){
					
					this.setDataSet(item,rspRecord[item]);
				}
				
			}
			
			this.dataset.beforeFirst();
			
		}
		
		
	},
	
	getDataValue: function(){	
		return this.rsp.action.message;		
	},
	
	/* 弹窗 */
	switchWindow: function(element){
		
		var url;
		
		if(element){
			url = element.url;
		}
				
		/*if(Yacon.isEmpty(url)){			
			url = this.pagePath;
		}*/
		
		url = Yacon.addUrlParam("parentElement", this.elementID, url);
		
		if(!Yacon.isEmpty(element)){
			url = Yacon.addUrlParam("lilyWindowWidth" , element.width , url);
			url = Yacon.addUrlParam("lilyWindowHeight" , element.height , url);
		}
	
		var dispatch = new Yacon.TDispatch({
			url : url
		});
		
		dispatch.postPage();
		
		this.rsp = dispatch.rsp;
		
	},
	
	switchPage: function(url){
		
		var dispatch = new Yacon.TDispatch({
			url : url
		});
		
		dispatch.postPage();
		
		this.rsp = dispatch.rsp;
	},
	
	free:function(){
		
		if(this.action){
			this.action.free();
		}
		
		if(this.dataset){
			this.dataset.free();
		}
		
		if(this.body){
			this.body.free();
		}
		
		if(this.record){
			this.record.free();
		}
		
	},	
	
	/* 设置数据集 */
	setDataSet: function(fieldName,fieldValue,fieldOldValue){
		
		if(Yacon.isEmpty(fieldName)){
			return;
		}
		
		if(fieldValue == undefined){
			return;
		}
		
		if(Yacon.isEmpty(fieldValue)){
			fieldValue = "";
		}
		
		if(Yacon.isEmpty(fieldOldValue)){
			fieldOldValue = fieldValue;
		}
		
		var record = new Yacon.container.Record();
		
		record.setFieldValue("fieldvalue",fieldValue);
		record.setFieldValue("fieldoldvalue",fieldOldValue);
		
		this.setFieldValue(fieldName,record);
		
	},
	
	/* 清空DataSet */
	clearDataSet: function(){
		delete this.dataset;
		this.dataset = new Yacon.container.Table();	
	},
	
	/* 加载数据 */
	instData:function(){
		this.component.instData();
	},
	
	/* 展示数据 */
	showData:function(){
		this.component.showData();
	},
	
	getDataSet: function(choice){
		
		if(Yacon.isEmpty(choice)){
			choice = "flat";
		}
		
		this.dataset = new Yacon.container.Table();	
		
		var search = "div[lily-id='"+this.component.elementID+"'][lily-type='"+this.component.elementType+"']";
		
		if(choice == "flat"){
			
			var datas = $(search+" tbody tr.active");
			
			for(var i=0;i<datas.length;i++){
				
				this.createRecord();			
				var tds = datas.eq(i).find("td");			
				for(var j=0;j<tds.length;j++){
					
					var fieldName = tds.eq(j).attr("field_name");
					var fieldValue = tds.eq(j).attr("field_val");
					var fieldOldValue = tds.eq(j).attr("field_old_val");
					
					if(Yacon.isEmpty(fieldOldValue)){
						this.setDataSet(fieldName,fieldValue);
					}else{
						this.setDataSet(fieldName,fieldValue,fieldOldValue);
					}
						
				}
						
			}
			
		}else{
			
			var checks = $(search+" .panel-body .table-body input:checked").parent().parent().parent();
			
			for(var i=0;i<checks.length;i++){
			
				this.createRecord();			
				var tds = checks.eq(i).find("td");			
				for(var j=0;j<tds.length;j++){
					
					var fieldName = tds.eq(j).attr("field_name");
					var fieldValue = tds.eq(j).attr("field_val");
					
					var fieldOldValue = tds.eq(j).attr("field_old_val");
					
					if(Yacon.isEmpty(fieldOldValue)){
						this.setDataSet(fieldName,fieldValue);
					}else{
						this.setDataSet(fieldName,fieldValue,fieldOldValue);
					}
						
				}
						
			}
			
		}
		
		/* 从表 */
		if(!Yacon.isEmpty(this.component.view.grid.master)){
			
			var masterID = this.component.view.grid.master.id;
			var parentGrid = this.page.find(masterID);
			parentGrid.getDataSet();
			
			var params = this.component.view.grid.master.fields;		
			for(var i=0;i<params.length;i++){
				var parentKey = params[i].fieldName;
				var activekey = params[i].foreignName;				
				this.setBody(activekey,parentGrid.getFieldValue(parentKey));			
			}
			
		}
			
		return this.dataset;
		
	},
	
	getCheckDataSet: function(){
		
		this.dataset = new Yacon.container.Table();	
		
		var choice = this.component.view.grid.choice;
		
		var search = "div[lily-id='"+this.component.elementID+"'][lily-type='"+this.component.elementType+"']";
		
		if(choice == "flat"){
			
			var datas = $(search+" tbody tr.active");
			
			for(var i=0;i<datas.length;i++){
				
				this.createRecord();			
				var tds = datas.eq(i).find("td");			
				for(var j=0;j<tds.length;j++){
					
					var fieldName = tds.eq(j).attr("field_name");
					var fieldValue = tds.eq(j).attr("field_val");
					
					var fieldOldValue = tds.eq(j).attr("field_old_val");
					
					if(Yacon.isEmpty(fieldOldValue)){
						this.setDataSet(fieldName,fieldValue);
					}else{
						this.setDataSet(fieldName,fieldValue,fieldOldValue);
					}
					
						
				}
						
			}
			
		}else{
			
			var checks = $(search+" .panel-body .table-body input:checked").parent().parent().parent();
			
			for(var i=0;i<checks.length;i++){
			
				this.createRecord();			
				var tds = checks.eq(i).find("td");			
				for(var j=0;j<tds.length;j++){
					
					var fieldName = tds.eq(j).attr("field_name");
					var fieldValue = tds.eq(j).attr("field_val");
					
					var fieldOldValue = tds.eq(j).attr("field_old_val");
					
					if(Yacon.isEmpty(fieldOldValue)){
						this.setDataSet(fieldName,fieldValue);
					}else{
						this.setDataSet(fieldName,fieldValue,fieldOldValue);
					}
						
				}
						
			}
			
		}
		
		this.dataset.beforeFirst();
		
		/* 从表 */
		if(!Yacon.isEmpty(this.component.view.grid.master)){
			
			var masterID = this.component.view.grid.master.id;
			var parentGrid = this.page.find(masterID);
			parentGrid.getDataSet();
			
			var params = this.component.view.grid.master.fields;		
			for(var i=0;i<params.length;i++){
				var parentKey = params[i].fieldName;
				var activekey = params[i].foreignName;				
				this.setBody(activekey,parentGrid.getFieldValue(parentKey));			
			}
			
		}
			
		return this.dataset;
		
	},
	
	getDataSetValue: function(fieldName){
				
	    var active_field = this.dataset.getFieldValue(fieldName);
	
	    if(active_field){
		    return active_field.getFieldValue("fieldvalue");
		}

		return "";
		
	},
	
	getDataSetOldValue: function(fieldName){
		
		var active_field = this.dataset.getFieldValue(fieldName);
		
	    if(active_field){
		    return active_field.getFieldValue("fieldoldvalue");
		}

		return "";
		
	},
	
	/* 刷新数据 */
	refresh:function(){
		
		if(this.refreshMethod){
			this.setAction("methodName",this.refreshMethod);
		}
		
		else{
			this.setAction("methodName","refresh");
		}
		
		var dispatch = new Yacon.TDispatch({
			url : "/"+this.appCode+"/managerService",
			req : this.getJSON(),
			before:{
				method:"_lily_beforeRefresh",
				param:[this]
			},
			after:{
				method:"_lily_afterRefresh",
				param:[this]
			},
			dataSet:this
		});
		
		dispatch.post(true);
				
	},
	
	setWhereField: function(fieldName,fieldValue){
		this.setDataSet(fieldName,fieldValue,fieldValue);
	},
	
	getDataSetCount: function(){	
		return this.dataset.getRecordCount();		
	},
	
	next: function(){
		
		if(this.dataset){
			return this.dataset.next();
		}
		
		return false;
		
	},
	
	getUrl:function(){
		
		var url = this.contextPath + "/managerService?switch_xml="+this.getJSON();
		
		return url;
		
	},
	
	isEdit: function(){
		var type =  this.getAction("type");
		if(type == "2" || type == 2){
			return true;
		}else{
			return false;
		}
	},
	
	isInsert: function(){
		var type =  this.getAction("type");
		if(type == "1" || type == 1){
			return true;
		}else{
			return false;
		}
	},
	
	isDelete: function(){
		var type =  this.getAction("type");
		if(type == "3" || type == 3){
			return true;
		}else{
			return false;
		}
	}

});

function _lily_beforeRefresh(dataSet){
	
	/* 过屏 */
	if(!Yacon.isEmpty(dataSet.component.spinner)){
		dataSet.component.spinShow();
	} 
	
};

function _lily_afterRefresh(dataSet){
	
	if(dataSet.component.elementType == "tree"){
		
	}else{
		dataSet.component.refreshElement();
	}
	
	/* 过屏 */
	if(!Yacon.isEmpty(dataSet.component.spinner)){
		dataSet.component.spinHidden();
	}
};
;
///<jscompress sourcefile="ViewSet.js" />
;
///<jscompress sourcefile="Field.js" />
Yacon.container.Field = function(){
	this.fFieldName    = "";
	this.fFieldValue   = "";
	this.parent        = null;
};

Yacon.container.Field.Extend(Object,{
	
	/* 获取字段名 */
	getFieldName :function(){
		return this.fFieldName;
	},
	
	/* 设置字段名 */
	setFieldName:function(fieldName){
		if(fieldName)
			this.fFieldName = fieldName;
	},
	
	/* 获取字段值 */
	getFieldValue:function(){
		return this.fFieldValue;
	},
	
	/* 设置字段值 */
	setFieldValue:function(fieldValue){
		
		if(fieldValue instanceof String){
			fieldValue = fieldValue.encode();
		}
		
		this.fFieldValue = fieldValue;
	},
	
	/* 设置父记录 */
	setParent:function(record){
		this.parent = record;
	},
	
	/* 获取父记录 */
	getParent:function(){
		return this.parent;
	}
		
});;
///<jscompress sourcefile="Record.js" />
Yacon.container.Record = function(){
	this.fieldNames    =  new Array();
	this.fieldList     =  new Array();
	this.factvieField  =  null;
	this.parent = null;
};

Yacon.container.Record.Extend(Object,{
	
	/* 添加字段 */
	addField :function(field)
	{
		if (Yacon.isEmpty(field))
			return;
		
		if (Yacon.isEmpty(field.getFieldName()))
			return;
		
		var index = this.fieldNames.indexOf(field.getFieldName().toLowerCase());
	    if (index>-1)
		{
			field.setParent(this);
			this.fieldList[index] = field;
		}else
		{
			field.setParent(this);			 
			this.fieldNames.add(field.getFieldName().toLowerCase());
			this.fieldList.add(field);
		}
	    this.factvieField = field;
	},
	
	/* 获取字段 */
	getField: function(fieldIndex)
	{
		if (Yacon.isEmpty(fieldIndex))
			return this.factvieField;
		else
			this.factvieField = null;
		
		if (Yacon.isNumber(fieldIndex))
		{
			this.factvieField = this.fieldList.get(fieldIndex);
			 
	    }else  if (Yacon.isString(fieldIndex))
	    {
	    	var index = this.fieldNames.indexOf(fieldIndex.toLowerCase());
		    if (index>-1)
			{
		    	this.factvieField = this.fieldList.get(index);
			}
	    }
		return this.factvieField;	
	},
	
	/* 获取字段值 */
	getFieldValue: function(fieldIndex)
	{
		if (this.getField(fieldIndex) == null)
		{
			var fieldValue = "";
			
			return fieldValue;
			
		}else
		{
			return this.factvieField.getFieldValue();
		}
	},
	
	/* 设置字段值 */
	setFieldValue: function(fieldName,fieldValue)
	{
		if (this.getField(fieldName) == null)
			this.creatField(fieldName,fieldValue);
		else
			this.factvieField.setFieldValue(fieldValue);
	},
	
	/* 创建字段 */
	creatField: function(fieldName,fieldValue)
	{
		if (Yacon.isEmpty(fieldName))
			return null;
		
		this.factvieField = new Yacon.container.Field();
		this.factvieField.setFieldName(fieldName);
		this.factvieField.setFieldValue(fieldValue);
		this.addField(this.factvieField);
		return this.factvieField;
	},
	
	/* 释放 */
	free: function()
	{
		this.fieldNames.clear();
		this.fieldList.clear();
	},
	
	/* 获取字段数 */
	getFieldCount: function(){
		return this.fieldNames.length;
	},
	
	getParent : function(){
		return this.parent;
	},
	
	setParent: function(table){
		this.parent = table;
	}
	
	
	
});;
///<jscompress sourcefile="Table.js" />
Yacon.container.Table = function(){
	this.recordList     =  new Array();
	this.activeIdx = -1;
	this.activeRecord = null;
};

Yacon.container.Table.Extend(Object,{
	
	/* 创建记录 */
	createRecord: function(){
		
		this.activeIdx ++;		
		this.activeRecord = new Yacon.container.Record();		
		this.recordList.add(this.activeRecord);
		this.activeRecord.setParent(this);
		
		return this.activeRecord;
	},
	
	/* 添加记录 */
	addRecord: function(record){	
		
		this.recordList.add(record);		
		this.activeIdx ++ ;		
		this.activeRecord = record;	
		
	},

	/* 遍历方法 */
	next: function(){
		
		var max =  this.recordList.length;
		
		this.activeIdx ++ ;
		
		if(this.activeIdx >= max){
			this.activeIdx = (max - 1);
			return false;
		}else{
			return true;
		}
		
	},
	
	/* 获取记录数 */
	getRecordCount: function(){
		return this.recordList.length;
	},
	
	/* 获取记录 */
	getRecord: function(){
		
		if(this.activeIdx == -1){
			this.createRecord();
		}
		
		this.activeRecord = this.recordList[this.activeIdx];
		
		return this.recordList[this.activeIdx];
	},
	
	/* 定位-1 */
	beforeFirst: function(){
		this.activeIdx = -1;
	},
	
	/* 获取第一条记录 */
	getFirstRecord:function(){
		this.activeIdx = 0;
		return this.getRecord();
	},
	
	/* 释放缓存 */
	free: function(){
		
		this.beforeFirst();
		while(this.next()){
			this.getRecord().free();
		}
		
		this.recordList.clear();	
	},
	
	/* 获取字段值 */
	getFieldValue: function(fieldName){
		this.getRecord();
		return this.activeRecord.getFieldValue(fieldName);
	},
	
	/* 设置字段值 */
	setFieldValue: function(fieldName,fieldValue){
		this.getRecord();
		this.activeRecord.setFieldValue(fieldName,fieldValue);
	}
	
});;
///<jscompress sourcefile="Component.js" />
Yacon.Component = function(){
	
};

Yacon.Component.Extend(Object,{
	
	layoutBefore: function(){
		
	},
	
	addEvents: function(){
		
	}
	
});

;
///<jscompress sourcefile="TForm.js" />
Yacon.widget.TForm = function(conText){
	
	Yacon.apply(this,conText);
	
	if(this.view){
		this.element = this.view;
		this.elementID = this.view.id;
		this.elementType = this.view.type;
	}
	
	this.items = new Yacon.container.Record();
	
	this.dropItems = new Yacon.container.Record();
	
};

Yacon.widget.TForm.prototype = {
		
	getHtml: function(){
		
		var html = "";
		
		html += "<div class='row-ht-fix'>"
		
		html += "<form class='form-horizontal' role='form' ";
		
		html += " lily-id='"+this.view.id+"' lily-type='form' ";
		
		html += " > ";
				
		this.layout = this.view.layout;
		
		var rowSize = this.layout.length;
		for(var i=0;i<rowSize;i++){
			
			var activeRow = this.layout[i];
			var colSize = activeRow.length;
			if(colSize <= 0){
				continue;
			}
			
			html += "<div class='form-group'>";
			
			for(var j=0;j<colSize;j++){
				
				var cell = activeRow[j];
				var comSize = cell.component.length;
				
				var className = "col-md-"+cell.width+" ";
				if(!Yacon.isEmpty(cell.offset)){
					className += " col-md-offset-"+cell.offset+" "
				}
				
				
				html += "<div class='"+className+"'>";
				
				for(var x=0;x<comSize;x++){
					
					var component = cell.component[x];
					
					html += this.getComponentHtml(component);
					
				}
				
				html += "</div>";
			}
			
			html += "</div>";
			
		}
		
		html += "</form>";
		
		html += "</div>";
		
		return html;
		
	},
	
	/* 获取组件HTML 部分信息 */
	getComponentHtml: function(component){
		
		var html = "";
		
		if(component.kind == "input"){		
			var activeElement = new Yacon.widget.TInput(component);
			activeElement.parent = this;
			
			this.items.setFieldValue(component.name,activeElement);
			
			html += activeElement.getHtml();			
		}
		
		else if(component.kind == "drop"){
			
			var activeElement = new Yacon.widget.TDrop(component);
			activeElement.parent = this;
			
			this.items.setFieldValue(component.name,activeElement);
			
			//联动存储信息
			if(!Yacon.isEmpty(component.relaID)){
				this.dropItems.setFieldValue(component.relaID,activeElement);
			}
			
			html += activeElement.getHtml();
			
		}
		
		else if(component.kind == "dropdate"){
			
			var activeElement = new Yacon.widget.TDropDate(component);
			activeElement.parent = this;
			
			html += activeElement.getHtml();
			
		}
		
		else if(component.kind == "droptime"){
			
			var activeElement = new Yacon.widget.TDropDate(component);
			activeElement.parent = this;
			html += activeElement.getHtml();
			
		}
		
		else if(component.kind == "droptimestamp"){
			
			var activeElement = new Yacon.widget.TDropDate(component);
			activeElement.parent = this;
			
			html += activeElement.getHtml();
			
		}
		
		else if(component.kind == "textarea"){
			
			var activeElement = new Yacon.widget.TTextArea(component);
			activeElement.parent = this;
			
			this.items.setFieldValue(component.name,activeElement);
			
			html += activeElement.getHtml();
			
		}
		
		else if(component.kind == "button"){
			html += "&nbsp;&nbsp;&nbsp;";
			
			var activeElement = new Yacon.widget.TButton(component);
			activeElement.parent = this;
			html += activeElement.getFormHtml();
			
		}
		
		else if(component.kind == "check"){
			
			var activeElement = new Yacon.widget.TCheck(component);
			activeElement.parent = this;
			
			html += activeElement.getHtml();
			
		}
		
		else if(component.kind == "radio"){
			
			var activeElement = new Yacon.widget.TRadio(component);
			activeElement.parent = this;
			
			html += activeElement.getHtml();
			
		}
		
		else if(component.kind == "label"){
			
			var activeElement = new Yacon.widget.TLabel(component);
			activeElement.parent = this;
			
			html += activeElement.getHtml();
			
		}
		
		else if(component.kind == "progress"){
			
			var activeElement = new Yacon.widget.TProgress(component);
			activeElement.parent = this;
			
			html += activeElement.getHtml();
			
		}
		
		return html;
	},
	
	addEvents: function(){
		
		Yacon.callBack(this.elementID+"_beforeEvent", [this,this.page]);
		
		var self = this;
		
		var search = this.page.element.search + " form[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		$(search+" button[lily-player='button']").unbind("click");
		$(search+" button[lily-player='button']").click(function(e){		
			
			var button = new Yacon.widget.TButton($(this));
			
			button.page = self.page;
			button.component = self;
			
			button.addEvent();	
			
		});
		
		var dateEles = $(search).find(".date.form_date");
		if(dateEles.length > 0){		
			this.dropdate = new Yacon.widget.TDropDate();		
			this.dropdate.addEvent();
		}
		
		for(var i=0;i<this.items.getFieldCount();i++){
			this.items.getFieldValue(i).addEvent();
		}
		
		Yacon.callBack(this.elementID+"_afterEvent", [this,this.page]);
		
	},
	
	layoutBefore : function(){
		
	},
	
	instData : function(dataSet){
		
		if(Yacon.isEmpty(dataSet)){
			dataSet = this.parent.dataSet;
		}
		
		if(Yacon.isEmpty(dataSet)){
			return;
		}
		
		var search = this.page.element.search + " form[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";	
		var alls = $(search+" .lily-field");
		
		if(alls){
			
			var size = alls.length;		
			
			for(var i=0;i<size;i++){
			
				var active = alls.eq(i);
				var fieldName = active.attr("field-name");
				var fieldValue = active.val();
				
				if(Yacon.isNull(fieldValue)){
					fieldValue = "";
				}
				
				//复选框
				var fieldTyp = active.attr("field-type");
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "check"){
					var allChecks = active.find("input[type='checkbox']:checked");
					
					for(var j=0;j<allChecks.length;j++){
						fieldValue += ","+allChecks.eq(j).attr("field-key") ;
					}
					
					if(fieldValue.startsWith(",")){
						fieldValue = fieldValue.substring(1);
					}
				}
							
				//单选框
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "radio"){
					var allChecks = active.find("input[type='radio']:checked");
					for(var j=0;j<allChecks.length;j++){
						fieldValue += ","+allChecks.eq(j).attr("field-key") ;
					}
					
					if(fieldValue.startsWith(",")){
						fieldValue = fieldValue.substring(1);
					}
					
				}
				
				//Label信息
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "label"){
					fieldValue = active.html();
				}
				
				var fieldOldValue = fieldValue;
				
				dataSet.setBody(fieldName,fieldValue);
				
			}
			
		}
		
	},
	
	/* 重置 */
	reset: function(){
		
		var search = this.page.element.search + " form[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		var forms = $(search);
		
		if(forms.length >= 1){
			forms[0].reset();
		}
		
		/* 单独信息重置 */
		var lilyFields = $(search+" .lily-field");
		for(var i=0;i<lilyFields.length;i++){
			
			var active = lilyFields.eq(i);
			var fieldTyp = active.attr("field-type");
			
			if(fieldTyp == "check"){
				
				var allChecks = active.find("input[type='checkbox']:checked");
				
				for(var j=0;j<allChecks.length;j++){
					allChecks.eq(j).prop("checked","false");
				}
				
			}
			
			else if(fieldTyp == "radio"){
				
				var allChecks = active.find("input[type='radio']:checked");
				
				for(var j=0;j<allChecks.length;j++){
					allChecks.eq(j).prop("checked","false");
				}
			}

			else if(fieldTyp == "label"){
				active.html("");
			}
			
		}
		
		this.instData();
		
	},
	
	/* 值 */
	value: function(fieldName,value){
		
		fieldName = fieldName.toUpperCase();
		
		var search = this.page.element.search + " form[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		var activeField = $(search+" .lily-field[field-name='"+fieldName+"']");
		
		if(!Yacon.isEmpty(value)){
			activeField.val(value);
			return value;
		}else{
			return activeField.val();
		}
		
	},
	
	text: function(fieldName,value){
		
		fieldName = fieldName.toUpperCase();
		
		var search = this.page.element.search + " form[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		var activeField = $(search+" .lily-field[field-name='"+fieldName+"']");
		
		if(!Yacon.isEmpty(value)){
			activeField.text(value);
			return value;
		}else{
			return activeField.text();
		}
	},
	
	html: function(fieldName,value){
		
		fieldName = fieldName.toUpperCase();
		
		var search = this.page.element.search + " form[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		var activeField = $(search+" .lily-field[field-name='"+fieldName+"']");
		
		if(!Yacon.isEmpty(value)){
			activeField.html(value);
			return value;
		}else{
			return activeField.html();
		}
	},
	
	select: function(fieldName,fieldValue,fieldText){
		
		fieldName = fieldName.toUpperCase();
		
		if(Yacon.isEmpty(fieldText)){
			fieldText = fieldValue;
		}
		
		var search = this.page.element.search + " form[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		var activeField = $(search+" .lily-field[field-name='"+fieldName+"']");
		
		if(activeField.find("option[value='"+fieldValue+"']").length <= 0){
			activeField.append("<option value='"+fieldValue+"'>"+fieldText+"<option>");
		}
		
		activeField.find("option[value='"+fieldValue+"']").eq(0).prop("selected","true");
		
	},
	
	disabled: function(fieldName){
		
		fieldName = fieldName.toUpperCase();
		
		var search = this.page.element.search + " form[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		var activeField = $(search+" .lily-field[field-name='"+fieldName+"']");
		
		var parent = activeField.parent().parent();
		
		activeField.prop("disabled","true");
		
		parent.find(".bk-bg-primary").removeClass("bk-bg-primary").addClass("bk-bg-brown");
		
		
	},
	
	check: function(fieldName,fieldValue){
		
		fieldName = fieldName.toUpperCase();
		
		var search = this.page.element.search + " form[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		var activeField = $(search+" .lily-field[field-name='"+fieldName+"']");
		
		if(fieldValue == undefined){
			
			fieldValue = "";
			
			var fieldTyp = activeField.attr("field-type");
			
			if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "check"){
				
				var allChecks = activeField.find("input[type='checkbox']:checked");
				for(var j=0;j<allChecks.length;j++){
					fieldValue += ","+allChecks.eq(j).attr("field-key") ;
				}
				
				if(fieldValue.startsWith(",")){
					fieldValue = fieldValue.substring(1);
				}	
			}
			
			return fieldValue;
		}
		
		else{
			
			var fieldTyp = activeField.attr("field-type");
			
			/* 复选框 */
			if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "check"){
				var item = fieldValue.split(",");
				for(var j=0;j<item.length;j++){					
					var itemVal = item[j];				
					activeField.find("input[field-key='"+itemVal+"']")
					         .prop("checked","true");				
				}			
			}
			
		}
		
	},
	
	radio: function(fieldName,fieldValue){
		
		fieldName = fieldName.toUpperCase();
		
		var search = this.page.element.search + " form[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		var activeField = $(search+" .lily-field[field-name='"+fieldName+"']");
		
		if(fieldValue == undefined){
			
			fieldValue = "";
			
			var fieldTyp = activeField.attr("field-type");
			
			if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "radio"){
				
				var allChecks = activeField.find("input[type='radio']:checked");
				for(var j=0;j<allChecks.length;j++){
					fieldValue += ","+allChecks.eq(j).attr("field-key") ;
				}
				
				if(fieldValue.startsWith(",")){
					fieldValue = fieldValue.substring(1);
				}	
			}
			
			return fieldValue;
		}
		
		else{
			
			var fieldTyp = activeField.attr("field-type");
			
			/* 复选框 */
			if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "radio"){
				
				activeField.find("input[field-key='"+fieldValue+"']")
				           .prop("checked","true");				
						
			}
			
		}
		
	},
	
	progress: function(fieldName,fieldValue){
		
		fieldName = fieldName.toUpperCase();
		
		var search = this.page.element.search + " form[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		var activeField = $(search+" .lily-field[field-name='"+fieldName+"']");
		
		if(fieldValue == undefined){
			
			fieldValue = "";
			
			var fieldTyp = activeField.attr("field-type");
			
			if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "progress"){
				
				fieldValue = activeField.attr("aria-valuenow");
				
			}
			
			return fieldValue;
		}
		
		else{
			
			if(Yacon.isString(fieldValue)){
				if(fieldValue.endWith("%")){
					fieldValue = fieldValue.substring(0,fieldValue.length-1);
				}
			}
			
			var fieldTyp = activeField.attr("field-type");
			
			/* 复选框 */
			if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "progress"){
				
				activeField.attr("aria-valuenow",fieldValue);
				activeField.css("width",fieldValue+"%");
				
				activeField.html(fieldValue+"%");
						
			}
			
		}
		
		
	},
	
	find: function(itemID){
		return this.items.getFieldValue(itemID);
	}
};;
///<jscompress sourcefile="TMenu.js" />
Yacon.widget.TMenu = function(element){
	this.element = element;
};

Yacon.widget.TMenu.prototype = {
	
	getHtml : function(){
		
		var html = "";
		
		if(this.element){
			
			if(this.element.type == "top"){
				html += this.getTopHtml();
			}
			
			else if(this.element.type == "right"){
				html += this.getRightHtml();
			}
			
			else if(this.element.type == "bottom"){
				html += this.getBottomHtml();
			}
				
		}
		
		return html;
		
	},
	
	/* 顶部Panel菜单 */
	getTopHtml: function(){
		
		var html = "";
		
		html += "<div class='panel-actions fix'>";
		
		var buttons = this.element.button;
		var size = buttons.length;
		for(var i=0;i<size;i++){
			var activeBtn = new Yacon.widget.TButton(buttons[i]);
			html += activeBtn.getTopHtml();
		}
		
		html += "</div>";
		
		return html;
		
	},
	
	/* 底部Bottom菜单 */
	getBottomHtml: function(){
		
		var html = "";
		
		html += "<div class='pull-right' isWindowControl='true' style='line-height:29px;'>";
		
		var buttons = this.element.button;
		
		for(var i=0;i<buttons.length;i++){
			html += new Yacon.widget.TButton(buttons[i]).getBottomHtml();
			html += "&nbsp;&nbsp;";
		}
		
		html += "</div>";
		
		return html;
		
	},
	
	/* 右键菜单 */
	getRightHtml: function(id){
		
		if(Yacon.isEmpty(id)){
			id = this.parent.element.id +"-menu";
		}
		
		var html = "";
		
		html += "<div id='"+id+"'>";
		
		html += "<ul class='dropdown-menu' role='menu'>";
		
		var buttons = this.element.button;
		var size = buttons.length;
		for(var i=0;i<size;i++){
			var activeBtn = new Yacon.widget.TButton(buttons[i]);
			html += activeBtn.getRightHtml();
		}
		
		html += "</ul>";
		
		html += "</div>";
		
		return html;
		
	},
	
	/* 顶部点击事件 */
	addTopClick: function(child){
		
		var self = this;
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		
		if(!Yacon.isEmpty(child)){
			search = search+" "+child+" ";
		}
		
		$(search+" a[lily-player='button']").unbind("click");
		$(search+" a[lily-player='button']").click(function(e){	
			
			var button = new Yacon.widget.TButton($(this));
			
			button.dataSet = self.dataSet;
			button.menu = self;
			button.page = self.page;
			button.component = self.parent;
			
			button.addEvent();
			
		});
		
	},
	
	/* 右键点击事件 */
	addRightClick:function(child){
		
		var self = this;
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		
		if(!Yacon.isEmpty(child)){
			search = search+" "+child+" ";
		}
		
		$(search+" li[lily-player='button']").unbind("click");
		$(search+" li[lily-player='button']").click(function(e){		
			
			var button = new Yacon.widget.TButton($(this));
			
			button.dataSet = self.dataSet;
			button.menu = self;
			button.page = self.page;
			button.component = self.parent;
			
			button.addEvent();		
		});
		
	},
	
	/* 底部点击事件 */
	addBottomClick:function(child){
		
		var self = this;
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		
		if(!Yacon.isEmpty(child)){
			search = search+" "+child+" ";
		}
		
		$(search+" button[lily-player='button']").unbind("click");
		$(search+" button[lily-player='button']").click(function(e){		
			
			var button = new Yacon.widget.TButton($(this));
			
			button.dataSet = self.dataSet;
			button.menu = self;
			button.page = self.page;
			button.component = self.parent;
			
			button.addEvent();		
		});
		
	}
		
};;
///<jscompress sourcefile="TPanel.js" />
Yacon.widget.TPanel = function(conText){	
	
	Yacon.apply(this,conText);
	
	if(this.view){
		this.element = this.view;
		this.panel = this.view.panel;
		this.elementID = this.view.id;
		this.elementType = this.view.type;
	}
};

Yacon.widget.TPanel.prototype = {
	
	getHtml: function(){
		
		var html = "";
		
		html += "<div class='panel row-ht-auto col' style='border:1px solid #34495e;margin-bottom: 0px;' ";
		
		html += " lily-id='"+this.elementID+"' lily-type='"+this.elementType+"' ";
		
		html += " >";
		
		if(this.panel.title){
			html += this.getHeadHtml();
		}
			
		html += this.getBodyHtml();
		
		if(this.panel.bottom){
			html += this.getFootHtml();
		}
		
		html += "</div>";
		
		return html;
		
	},
	
	/* 获取头Html */
	getHeadHtml: function(){
		
		var html = "";
		
		html += "<div class='panel-heading bk-bg-primary row-ht-fix'>";
		
		if(this.panel.isClose){
			html += "<button type='button' class='close panel-close-fix' data-dismiss='modal'>";
			html += "<span aria-hidden='true'>×</span> <span class='sr-only'>Close</span>";
			html += "</button>";
		}
		
		var ico = Yacon.def.window_ico;
		if(this.panel.title.ico){
			ico = this.panel.title.ico;
		}
		
		html += "<h5><span class='"+ico+"'></span>&nbsp;&nbsp;"+this.panel.title.name+"</h5>";
		
		html += "</div>";
		
		return html;		
	},
	
	/* 获取体HTML信息 */
	getBodyHtml: function(){
		
		var html = "";
		
		html += "<div class='panel-body row-ht-auto col' style='overflow-y:auto;'>";
		
		var content = this.panel.content;
		var contentSize = content.length;
		
		for(var i=0;i<contentSize;i++){
			
			var component = content[i];
			
			if(component.kind == "form"){
				
				var form = new Yacon.widget.TForm({view:component,page:this.page});
				
				form.parent = this;
				this.page.addComponet(form);
		
				html += form.getHtml();
				
			}
			
			else if(component.kind == "tree"){
				
				var tree = new Yacon.component.TTree({view:component,page:this.page});
				
				tree.parent = this;
				
				this.page.addComponet(tree);
				
				html += tree.getHtml();
				
			}
			
			else if(component.kind == "toutframe"){
				
				var frame = new Yacon.widget.TOutFrame({view:component,page:this.page});
				
				frame.parent = this;
				
				this.page.addComponet(frame);
				
				html += frame.getHtml();
				
			}
			
			else if(component.kind == "charts"){
				
				var charts = new Yacon.component.ECharts({view:component,page:this.page});
				charts.parent = this;			
				this.page.addComponet(charts);
				
				html += charts.getHtml();
				
			}
			
			else if(component.kind == "picbox"){
				
				var picbox = new Yacon.widget.TPictureBox({view:component,page:this.page});
				picbox.parent = this;
				this.page.addComponet(picbox);
				
				html += picbox.getHtml();
				
			}
			
		}
		
		html += "</div>";
		
		return html;
		
	},
	
	/* 获取底部Html */
	getFootHtml: function(){
		
		var html = "";
		
		html += "<div class='panel-footer bk-bg-primary row-ht-fix'>";
		
		html += "<div class='pull-right' isWindowControl='true'>";
		
		var buttons = this.panel.bottom.buttons;	
		for(var i=0;i<buttons.length;i++){
			html += new Yacon.widget.TButton(buttons[i]).getBottomHtml();
			html += "&nbsp;&nbsp;";
		}
		
		html += "</div>";
		
		html += "<div class='clearfix'> </div>";
		
		html += "</div>";
		
		return html;
		
	},
	
	addEvents: function(){
		
		Yacon.callBack(this.elementID+"_beforeEvent", [this,this.page]);
		
		var self = this;
		
		var page = this.page;
		var windows = this.page.windows;
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		$(search+" .panel-footer button[lily-player='button']").unbind("click");
		$(search+" .panel-footer button[lily-player='button']").click(function(e){	
			
			var button = new Yacon.widget.TButton($(this));
			
			button.dataSet = windows.dataSet;
			button.page = page;
			button.component = self;
				
			button.addEvent();
			
		});
		
		/* 时间控件处理 */
		new Yacon.widget.TDropDate().addEvent();
		
		Yacon.callBack(this.elementID+"_afterEvent", [this,this.page]);
		
	},
	
	layoutBefore: function(){
		
	}
		
};;
///<jscompress sourcefile="TSpin.js" />
/* 动态刷新效果JS */
Yacon.widget.TSpin = function(conText){	
	Yacon.apply(this,conText);
};

Yacon.widget.TSpin.prototype = {
	
	/* 创建蒙版 */
	createSpinner : function(searchStr){
		
		var target = $(searchStr);
		
		var height = Yacon.getWidthNumber(target.height());
		var width = Yacon.getWidthNumber(target.width());
		
		var heightPx = (height/2)+"px" ;
		var widthPx = (width/2)+"px" ;
		
		this.setting = {            
            lines: 13, // 花瓣数目
            length: 10, // 花瓣长度
            width: 10, // 花瓣宽度
            radius: 30, // 花瓣距中心半径
            corners: 1, // 花瓣圆滑度 (0-1)
            rotate: 0, // 花瓣旋转角度
            direction: 1, // 花瓣旋转方向 1: 顺时针, -1: 逆时针
            color: '#A3A3A3', // 花瓣颜色
            speed: 1, // 花瓣旋转速度
            trail: 60, // 花瓣旋转时的拖影(百分比)
            shadow: false, // 花瓣是否显示阴影
            hwaccel: false, //spinner 是否启用硬件加速及高速旋转            
            className: 'spinner', // spinner css 样式名称
            zIndex: 2e9, // spinner的z轴 (默认是2000000000)
            top: "50%", // spinner 相对父容器Top定位 单位 px
            left: "50%" // spinner 相对父容器Left定位 单位 px
        }; 
		
	},
	
	/* 展示 或隐藏 */
	spinOut: function(searchStr){		
		$(searchStr).spin(false);	
	},
	
	spinIn: function(searchStr){
		$(searchStr).spin(this.setting);
	},
	
	spinShow: function(searchStr){
		$(searchStr+" .spinner").css("display","block");	
	},
	
	spinHidden: function(searchStr){
		$(searchStr+" .spinner").css("display","none");
	}
		
};;
///<jscompress sourcefile="TTab.js" />
Yacon.widget.TTab = function(conText){	
	
	Yacon.apply(this,conText);
	
	if(this.view){
		this.element = this.view;
		this.elementID = this.view.id;
		this.elementType = this.view.type;
	}
	
};

Yacon.widget.TTab.prototype = {
	
	/* 获取HTML */	
	getHtml: function(){
		
		var html = "";
		
		html += "<div ";	
		html += " class='row-ht-auto col' ";	
		html += " lily-id='"+this.elementID+"' lily-type='"+this.elementType+"' ";		
		html += ">"
		
		/* 获取头信息 */	
		html += this.getTabHtml();
		
		/* 获取体信息 */
		html += this.getContentHtml();
		
		html += "</div>";
		
		return html;
		
	},
	
	/* 获取头HTML */
	getTabHtml: function(){
		
		var html = "";
		
		html  += "<div id='"+this.elementID+"_tag' class='row-ht-fix'>";
		
		if(this.view.style == "pill"){
			html += "<ul id='"+this.elementID+"' class='nav nav-pills' role='tablist' >"
		}else{
			html += "<ul id='"+this.elementID+"' class='nav nav-tabs' role='tablist' >"
		}
			
		//拼标签
		this.tabs = this.view.tabs;
		for(var i=0;i<this.tabs.length;i++){
			
			var activeTab = this.tabs[i];
			
			if(Yacon.isEmpty(activeTab.menu)){
				
				html += "<li role='presentation'>";
				
				if(this.view.style == "pill"){
					html += "<a href='#"+activeTab.id+"' id='"+activeTab.id+"_tab' role='tab' data-toggle='pill' aria-controls='"+activeTab.id+"' aria-expanded='false'>";			
				}else{
					html += "<a href='#"+activeTab.id+"' id='"+activeTab.id+"_tab' role='tab' data-toggle='tab' aria-controls='"+activeTab.id+"' aria-expanded='false'>";			
				}
						
				html += activeTab.name;
				
				html += "</a>"
				html += "</li>";
				
			}
			else{
				
				html += "<li role='presentation' class='dropdown'>";			
				html += "<a href='#' id='"+activeTab.id+"_tab' class='dropdown-toggle' data-toggle='dropdown' aria-controls='"+activeTab.id+"-contents' aria-expanded='false'>"+activeTab.name+" <span class='caret'></span></a>";				
				html += "<ul class='dropdown-menu' role='menu' aria-labelledby='"+activeTab.id+"_tab' id='"+activeTab.id+"_tab-contents'>";
				
				var menus = activeTab.menu;
				for(var j=0;j<menus.length;j++){
					
					var activeMenu = menus[j];
					
					html += "<li class=''>";
					
					if(this.view.style == "pill"){
						html += "<a  href='#"+activeMenu.id+"'  tabindex='-1'  role='tab'  id='"+activeMenu.id+"_tab'  data-toggle='pill'  aria-controls='"+activeMenu.id+"'  aria-expanded='false'>";					
						
					}else{
						html += "<a  href='#"+activeMenu.id+"'  tabindex='-1'  role='tab'  id='"+activeMenu.id+"_tab'  data-toggle='tab'  aria-controls='"+activeMenu.id+"'  aria-expanded='false'>";					
					}
					
					html += activeMenu.name;
					html += "</a>";						
					html += "</li>";
				}
				
				
				html += "</ul>";
				html += "</li>";
				
			}
			
			
		}
		
		html += "</ul>"
		
		html  += "</div>";
		
		return html;
	},
	
	/* 获取体HTML */
	getContentHtml: function(){
		
		var html = "";
		
		html  += "<div id='"+this.elementID+"_content' class='row-ht-auto tab-content col lily-frame' >";
		
		for(var i=0;i<this.tabs.length;i++){
			
			var activeTab = this.tabs[i];
			
			if(Yacon.isEmpty(activeTab.menu)){
				html += "<div role='tabpanel' class='tab-pane fade col' style='height:100%;' id='"+activeTab.id+"' aria-labelledby='"+activeTab.id+"_tab'>";
				
				html += "</div>";
			}else{
				
				var menus = activeTab.menu;
				for(var j=0;j<menus.length;j++){
					
					var activeMenu = menus[j];
					html += "<div role='tabpanel' class='tab-pane fade col' style='height:100%;' id='"+activeMenu.id+"' aria-labelledby='"+activeMenu.id+"_tab'>";
					
					html += "</div>";					
					
				}
				
			}
			
			
		}
		
		html  += "</div>";
		
		return html;		
	},
	
	layoutBefore: function(){
		
	},
	
	getTag: function(tagID){
		
		if(Yacon.isString(tagID)){
			tagID = tagID.trim().toUpperCase();
			
			for(var i=0;i<this.tabs.length;i++){
				var activeTab = this.tabs[i];
				var activeId = activeTab.id.trim().toUpperCase();
				
				if(activeId == tagID){
					return activeTab;
				}
				
				if(!Yacon.isEmpty(activeTab.menu)){
					var menus = activeTab.menu;

					for(var j=0;j<menus.length;j++){
						
						var activeMenu = menus[j];
						
						var childId = activeMenu.id.trim().toUpperCase();
						
						if(childId == tagID){
							return activeMenu;
						}
						
					}
						
				}
				
			}
		}
		
		if(Yacon.isNumber(tagID)){
			if(this.tabs.length > tagID && tagID >= 0){
				return this.tabs[tagID];
			}
		}
		
		return null;
	},
	
	addEvents: function(){
		
		this.dataSet = new Yacon.data.DataSet(this.page);
		var self = this;
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		//隐藏绑定方法
		$(search+' a[role="tab"]').on('hide.bs.tab', function (e) {
		    var tagID = $(this).attr("aria-controls");
		    $(search +" #"+ tagID).empty();
		});
		
		//展示绑定方法
		$(search+' a[role="tab"]').on('show.bs.tab', function (e) {
			
			$(search +" #"+ tagID).empty();
			
			var tagID = $(this).attr("aria-controls");
			
			var tagObj = self.getTag(tagID);
			var tagUrl = tagObj.url;
			
			if(!tagUrl.startsWith("http")){
				tagUrl = self.page.element.contextPath + tagUrl;
			}
			
			self.dataSet.switchPage(tagUrl);
			
			/* JS填充 */
			$(search +" #"+ tagID).append(self.dataSet.rsp);
			
			self.tagPage = window.page;
			self.tagPage.tags = self;
			
			var pageHtml = self.tagPage.getHtml();
			
			$(search +" #"+ tagID).append(pageHtml);
			
		});
		
		$(search+' a[role="tab"]').on('shown.bs.tab', function (e) {
			self.tagPage.layout();		
			self.tagPage.addEvents();
		});
		
		this.clickTag(this.view.active);
		
	},
	
	/**
	 * 点击标签
	 * @param tag
	 */
	clickTag: function(tag){
		
		var tagObj = this.getTag(tag);
		
		if(!Yacon.isEmpty(tagObj)){
			var tagID = tagObj.id;
			var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
			$(search+" a[role='tab'][aria-controls='"+tagID+"']").tab('show'); 
		}
		
		
	}
	
};;
///<jscompress sourcefile="TWindow.js" />
Yacon.widget.TWindow = function(element){	
	if(element){
		this.element = element;
		this.dataSet = this.element.dataSet;
	}
};

Yacon.widget.TWindow.prototype = {
	
	/* 展示页面信息 */
	show : function(srcLocation){
		
		var self = this;
		
		this.elementID = this.dataSet.elementID+"_window";
		var elementID = this.elementID;
		
		if(Yacon.isEmpty(this.element.width)){
			this.width = "70%";
		}else{
			this.width = this.element.width;
		}
		
		if(Yacon.isEmpty(this.element.height)){
			this.height = "";
		}else{
			this.height = this.element.height;
		}
		
		var html = "";
		
		html += "<div class='modal fade' id='"+this.elementID+"' tabindex='-1' role='dialog' lily-container='window' lily-player='twindow' >";		
		html += "<div class='modal-dialog' style='width:"+this.width+"; ";
		
		html += "' >"
		
		html += "<div class='modal-content' style='background-color: rgba(255, 255, 255, 0.6);'>";		
		html += "<div class='modal-body modal-fluid lily-frame col' ";
		
		var style = "padding:0px;";
		if(this.height != ""){
			style = "height:"+this.height+";";
		}
		
		html += " style='"+style+"' ";
		
		html += ">";
		
		html += "</div>";
		html += "</div>";	
		html += "</div>";		
		html += "</div>";
		
		$("body").append(html);		
		
		/* JS填充 */
		$("#"+this.elementID).append(this.dataSet.rsp);
		
		/* Html填充 */
		this.windowPage = window.page;
		this.windowPage.windows = this;
		
		var pageHtml = this.windowPage.getHtml();
		$("#"+this.elementID+" .modal-body.modal-fluid.lily-frame ").append(pageHtml);
		
		/* 底部 padding去除 */
		$("#"+this.elementID+" .modal-body .row:first").css("padding-top","0px");		
		$("#"+this.elementID).modal('show');
		
		$("#"+elementID).on('hidden.bs.modal', function (e) {
			
			$("#"+elementID).remove();
			
			if(Yacon.isString(self.element.close)){
				Yacon.callBack(self.element.close,[self,self.page]);
			}else{
				Yacon.callBackMethod(self.element.close);
			}
			
			var parentSize = $(".modal .modal-dialog").length;
			
			if(parentSize > 0){
				$("body").addClass("modal-open");
			}
			
		});
		
		$("#"+elementID).on('shown.bs.modal', function (e) {
			
			if(!Yacon.isEmpty(self.element.height)){			
				self.windowPage.layout();			
			}
			
			self.loadData();
			
			self.loadEvent();
			
			Yacon.callBack(self.elementID+"_afterOnload", [self,self.windowPage]);
			
		});
		
	},
	
	/* 事件装载 */
	loadEvent: function(){	
		this.windowPage.addEvents();	
	},
	
	/* 数据加载 */
	loadData: function(){
		
		if(!Yacon.isEmpty(this.dataSet)){
			
			var params = this.windowPage.element.parameter;
			
			if(!Yacon.isEmpty(params)){
				
				var state = params.state;
				
				if(state == "edit" || state == "past"){
					this.dataSet.showData();
				}
				
			}
			
/*			var type = this.dataSet.getAction("type");
			
			if(type == 2){
				this.dataSet.showData();
			}
			
			else if(type == 0){
				this.dataSet.showData();
			}*/
		}
		
	},
	
	closeWindow: function(){
		
		if(this.elementID){			
			$("#"+this.elementID).modal('hide');		
		}
		
	},
	
	layoutBefore: function(){
		
	}
	
	
};
;
///<jscompress sourcefile="TCarousel.js" />
Yacon.widget.TCarousel = function(conText){
	
	Yacon.apply(this,conText);
	
};

Yacon.widget.TCarousel.prototype = {
	
	getHtml : function(){
		
		var html = "";
		
		html += "<div id='"+this.elementID+"' class='carousel slide' data-ride='carousel' data-wrap='"+Yacon.isTrue(this.isWrap)+"'>";
		
		/* 列表图片 */
		html += "<div class='carousel-inner' role='listbox'>";
		
		for(var i=0;i<this.pictures.length;i++){
			
			var picture = this.pictures[i];
			
			html += "<div class='item' img-idx='"+i+"'>";
			
			html += "<img src='"+picture.view.src+"' alt='"+picture.view.alt+"' />";
			
			html += "</div>";
			
		}
		
		html += "</div>";
		
		/* 控制部分 */		
		html += "<a class='left carousel-control' href='#"+this.elementID+"' role='button' data-slide='prev'>";
		html += "<span class='glyphicon glyphicon-chevron-left' aria-hidden='true'></span>";
		html += "<span class='sr-only'>Previous</span>";
		html += "</a>";
		
		html += "<a class='right carousel-control' href='#"+this.elementID+"' role='button' data-slide='next'>";
		html += "<span class='glyphicon glyphicon-chevron-right' aria-hidden='true'></span>";
		html += "<span class='sr-only'>Next</span>";
		html += "</a>";
		
		html += "</div>";
		
		return html;
		
	}

};;
///<jscompress sourcefile="TPicture.js" />
Yacon.widget.TPicture = function(conText){
	
	Yacon.apply(this,conText);
	
};

Yacon.widget.TPicture.prototype = {
	
	
	getHtml : function(){
		
		var html = "";
		
		html += "<a href='javascript:void(0);' class='thumbnail' pic-idx='"+this.picIdx+"'>";
		
		html += "<img src='"+this.view.src+"' alt='"+this.view.alt+"' ";
		
		html += " style='width:100%;height:"+this.parent.view.picHeight+"' ";
		
		html += "/>";
		
		html += "</a>";
		
		return html;
		
	}

};;
///<jscompress sourcefile="TPictureBox.js" />
Yacon.widget.TPictureBox = function(conText){
	
	Yacon.apply(this,conText);
	
	if(!Yacon.isEmpty(this.view)){
		this.elementID = this.view.id;
		this.elementType = this.view.type;
	}
	
	this.picArray = new Array();
	
};

Yacon.widget.TPictureBox.prototype = {
	
	/* 获取HTML信息 */	
	getHtml : function(){
		
		var html = "";
		
		html += "<div ";		
		html += " lily-id='"+this.elementID+"' lily-type='"+this.elementType+"' ";	
		html += " style='padding-left:15px;padding-right:15px;' ";
		html += " >";
		
		if(!Yacon.isEmpty(this.view.title) || !Yacon.isEmpty(this.view.ico)){
			
			html += "<div style='margin-bottom:10px;border-bottom:2px solid #34495e;margin-left:-8px;margin-right:-8px;' >";
			
			html += "<button type='button' lily-player='button' btn-id='XXX' class='btn btn-default lily-form-button-blue' ";

			html += " style='border-radius: 0px;' ";
			
			html += ">";
			
			if(!Yacon.isEmpty(this.view.ico)){
				html += "<span class='"+this.view.ico+"'></span>";
				html += "&nbsp;&nbsp;";
			}
			
			if(!Yacon.isEmpty(this.view.title)){		
				html += this.view.title;			
			}
			
			if(Yacon.isTrue(this.view.isBadge)){
				html += "&nbsp;&nbsp;";
				html += "&nbsp;&nbsp;";
				html += "<span class='badge' style='background-color: #fff;color: #333;top:0px;'>"+this.view.pictures.length+"</span>";				
			}
	
			html += "</button>";
			html += "</div>";
			
		}
			
		html += "<div class='row' >";
		
		this.pictures = this.view.pictures;
		
		if(!Yacon.isEmpty(this.pictures)){
			for(var i=0;i<this.pictures.length;i++){
				
				html += "<div class='col-md-"+this.view.picWidth+"' >";
				
				var activePic = new Yacon.widget.TPicture({view:this.pictures[i],page:this.page,parent:this,picIdx:i});
				
				this.picArray.add(activePic);
				
				html += activePic.getHtml();
				
				html += "</div>";
				
			}
		}	
		
		html += "</div>";
		
		html += "<div class='big-image'>"			
		html += "<div class='modal fade' id='"+this.elementID+"_picBox' tabindex='-1' role='dialog'>";	
		html += "<div class='modal-dialog' role='document'>";
		html += "<div class='modal-content'>";
		html += "<div class='modal-body' style='padding:0px;'>";		
		html += "<img src='' alt='' />";		
		html += "</div>";
		html += "</div>";
		html += "</div>";
		html += "</div>";	
		html += "</div>";
		
		html += "<div class='scroll-image'>"			
		html += "<div class='modal fade' id='"+this.elementID+"_srollBox' tabindex='-1' role='dialog'>";	
		html += "<div class='modal-dialog' role='document'>";
		html += "<div class='modal-content'>";
		html += "<div class='modal-body' style='padding:0px;'>";		

		var carousel = new Yacon.widget.TCarousel({
			parent : this,
			pictures : this.picArray,
			elementID : this.elementID+"_srollBox_pics",
			elementType : "carousel",
			isWrap: this.view.isWrap
		});
		
		html += carousel.getHtml();
		
		html += "</div>";
		html += "</div>";
		html += "</div>";
		html += "</div>";	
		html += "</div>";
		
		html += "</div>";
		
		return html;
		
	},
	
	addEvents: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		var allPictures = $(search+" .row a");
		var self = this;
		
		for(var i=0;i<allPictures.length;i++){
			
			allPictures.eq(i).unbind("click");
			allPictures.eq(i).click(function(){
				
				var activeImg = $(this).find("img");
				
				if(Yacon.isTrue(self.view.isScroll)){
					
					var idx = $(this).attr("pic-idx");
					
					$("#"+self.elementID+"_srollBox").find("div.item").removeClass("active");
					$("#"+self.elementID+"_srollBox").find("div.item[img-idx='"+idx+"']").addClass("active");
					
					$("#"+self.elementID+"_srollBox").modal('show');
						
				}else{
					
					
					var showImg = $(search+" .big-image").find("img");
					
					showImg.prop("src",activeImg.prop("src"));
					showImg.prop("alt",activeImg.prop("alt"));
					
					$("#"+self.elementID+"_picBox").modal('show');
				}	
				
			});
			
		}
		
		$(function(){
			if(!Yacon.isTrue(self.view.isWrap)){
				$(".carousel").carousel({
					pause:true,
		            interval: false,
		            wrap:false
				});
			}
		});
		
	},
	
	layoutBefore: function(){
		
	}

};;
///<jscompress sourcefile="TFrame.js" />
Yacon.widget.TFrame = function(conText){
	
	Yacon.apply(this,conText);
	
	this.baseCreate();
	
};

Yacon.widget.TFrame.prototype = {
		
	baseCreate: function(){
		this.elementID = this.view.id;
		this.elementType = this.view.type;
		this.dataSet = new Yacon.data.DataSet(this.page);
	},
	
	/* 获取HTML信息 */	
	getHtml: function(){
		
		var html = "<div ";
		
		html += " lily-id='"+this.elementID+"' lily-type='"+this.elementType+"' ";
		
		html += ">";
		
		html += "<div id='"+this.elementID+"_window'>";
		
		html += "<div class='lily-frame col row-ht-inner class-frame' parentid='"+this.elementID+"'></div>";
		
		html += "</div>";
		
		html += "</div>";
		
		return html;
	},
	
	show: function(){
		
		if(this.elementID){
			
			if(Yacon.isEmpty(this.view.url) || "about:blank;" == this.view.url || "about:blank" == this.view.url){
				return;
			}
			
			this.dataSet.switchWindow({
				url : this.view.url
			});
			
			var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"'] ";		
			this.winHeight = $(search).parent().height();
			this.winWidth = $(search).parent().width();
			
			/* JS填充 */
			$(search +" .lily-frame").append(this.dataSet.rsp);
			
			if(Yacon.isEmpty(window.page)){
				return;
			}
			
			/* HTML填充 */
			this.framePage = window.page;
			this.framePage.frame = this;
			this.framePage.element.height = this.winHeight;
			this.framePage.element.width = this.winWidth;
			this.framePage.element.search = search;
			
			$(search +" .lily-frame").append(this.framePage.getHtml());
			
			//清除上边距
			$(search +" .lily-frame > div.row:first").css("padding-top","0px");			
			
			//布局处理
			this.framePage.layout();
			
			/* 绑定动作 */
			this.framePage.addEvents();
			
		}
		
	},
	
	/* 情况信息 */
	clear: function(){
		if(this.elementID){			
			var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";			
			$(search +" .lily-frame").empty();
		}
	},
	
	addEvents: function(){		
			
	},
	
	layoutBefore: function(){
		this.show();
	}
		
};;
///<jscompress sourcefile="TOutFrame.js" />
Yacon.widget.TOutFrame = function(conText){
	
	Yacon.apply(this,conText);
	
	this.baseCreate();
	
};

Yacon.widget.TOutFrame.prototype = {
	
	baseCreate: function(){
		this.elementID = this.view.id;
		this.elementType = this.view.type;
		this.url = this.page.element.contextPath + this.view.url;
	},

	getHtml: function(){
		
		var html = "<iframe ";
		
		html += " lily-id='"+this.elementID+"' lily-type='"+this.elementType+"' ";
		html += " bgcolor='#d4d0c8' id='frmContainer' src='' frameborder='0' ";
		html += " style='width:"+this.view.width+"; height:"+this.view.height+";' scrolling='auto' ";
		
		html += ">";
		
		html += "</iframe>";	
		
		return html;
	},
	
	show: function(){	
	   $("iframe[lily-id='"+this.elementID+"']").attr("src",this.url);	   
	},
	
	addEvents: function(){
		this.show();
	},
	
	layoutBefore: function(){
		
	}

};;
///<jscompress sourcefile="TButton.js" />
Yacon.widget.TButton = function(element){
	this.element = element;
};

Yacon.widget.TButton.prototype = {
	
	getHtml: function(){
		
			
	},
	
	/* 获取顶部按钮HTML */
	getTopHtml: function(){
		
		var html = "";
		
		html += "<a btn-id='"+this.element.id+"' lily-player='button' class='btn-setting' ";
		
		if(this.element.click){
			html += " view-click='"+this.element.click+"' ";
		}
		
		if(this.control){
			html += " view-control='"+this.control+"' ";
		}
		
		html += this.getPopHtml();
		
		html += " style='cursor:pointer;' >"
		
		html += "<span class='"+this.element.ico+" icon'></span></a>";
		
		return html;
		
	},
	
	/* 获取右键按钮HTML */
	getRightHtml: function(){
		
		var html = "";
		
		if(this.element.id == "divider"){
			html += "<li class='divider'></li>";
			return html;
		}
		
		html += "<li lily-player='button' btn-id='"+this.element.id+"' ";
		
		if(this.element.click){
			html += " view-click='"+this.element.click+"' ";
		}
		
		if(this.control){
			html += " view-control='"+this.control+"' ";
		}
		
		html += this.getPopHtml();
		
		html += ">";
		
		html += "<a tabindex='-1'>";
		
		html += "<span class='"+this.element.ico+"'></span>";
		html += "&nbsp;&nbsp;&nbsp;"
		html += this.element.name;
		
		html += "</a>";		
		html += "</li>"
		
		return html;
		
	},
	
	/* 获取底部Html方法 */
	getBottomHtml: function(){
		
		var html = "";
		
		html += "<button type='button' lily-player='button' btn-id='"+this.element.id+"' class='btn' style='color:black;' ";
		
		if(this.element.click){
			html += " view-click='"+this.element.click+"' ";
		}
		
		if(this.control){
			html += " view-control='"+this.control+"' ";
		}
		
		html += this.getPopHtml();
		
		html += ">";
		
		html += "<span class='"+this.element.ico+"'></span>";
		
		html += "&nbsp;&nbsp;";
		
		html += this.element.name;
		
		html += "</button>";
		
		return html;
		
	},
	
	getFormHtml: function(){
		
		var html = "";
		
		html += "<button type='button' lily-player='button' btn-id='"+this.element.id+"' class='btn btn-default lily-form-button-blue' ";
		
		if(this.element.click){
			html += " view-click='"+this.element.click+"' ";
		}
		
		if(this.control){
			html += " view-control='"+this.control+"' ";
		}
		
		html += this.getPopHtml();
		
		html += ">";
		
		html += "<span class='"+this.element.ico+"'></span>";
		
		html += "&nbsp;&nbsp;";
		
		html += this.element.name;
		
		html += "</button>";
		
		return html;
		
	},
	
	getPopHtml:function(){
		
		var html = "";
		
		if(Yacon.isEmpty(this.element.popTitle) && Yacon.isEmpty(this.element.popContent)){
			return html;
		}
		
		if(!Yacon.isEmpty(this.element.popTitle)){
			html += " title='"+this.element.popTitle+"' "
		}
		
		if(!Yacon.isEmpty(this.element.popContent)){
			html += " data-content='"+this.element.popContent+"' "
		}

		if(!Yacon.isEmpty(this.element.popPlace)){
			html += " data-placement='"+this.element.popPlace+"' ";
		}
		
		html += " data-container='body' ";
		
		html += " data-toggle='popover' ";
		
		return html;
	},
	
	/* 添加动作 */
	addEvent:function(){
		
		var btnId = this.element.attr("btn-id");
		
		window.page = this.component.page;
		
		if(btnId == "add"){
			this.addClick();
		}
		
		else if(btnId == "edit"){
			this.editClick();
		}
		
		else if(btnId == "delete"){
			this.deleteClick();
		}
		
		else if(btnId == "save"){
			this.saveClick();
		}
		
		else if(btnId == "exit"){
			this.exitClick();
		}
		
		else if(btnId == "refresh"){
			this.refreshClick();
		}
		
		else if(btnId == "expand"){
			this.expandClick();
		}
		
		else if(btnId == "cancle"){
			this.cancleClick();
		}
		
		else {
			this.ownerClick();
		}
		
	},
	
	/* 添加动作 - 弹窗 */
	addClick: function(){
		
		var isAccess = true;
		
		if(Yacon.isfireuserEvent(this.component.elementID+"_beforeInsert")){
			isAccess = Yacon.fireUserEvent(this.component.elementID+"_beforeInsert", [this.component,this.component.page]);
		}
		
		if(isAccess){
			
			var detail = this.menu.parent.element.detail;
			
			var width = detail.width;
			var height = detail.height;
			var path =  detail.path;
			
			this.dataSet.setAction("type","1");
			
			/* 非弹窗情况 */
			if(path == undefined){
				
				this.component.createRow();		
				this.component.createRowEvent();
				
			}
			
			else{
				
				path = Yacon.addUrlParam("state", "insert", path);
				
				if(!Yacon.isEmpty(detail.param)){
					var params = detail.param;
					for(var i=0;i<params.length;i++){
						
						var paramsKey = params[i].key;
						var foreignKey = params[i].foreign;
						
						if(foreignKey.startsWith("#")){							
							foreignKey = foreignKey.substring(1);					
							path = Yacon.addUrlParam(paramsKey,this.component.page.element.parameter[foreignKey],path);							
						}else{
							path = Yacon.addUrlParam(paramsKey,this.dataSet.getDataSetValue(foreignKey.toUpperCase()),path);							
						}
						
					}
				}
				
				/* 弹窗 */
				Yacon.showModal({
					heigth : height ,
					width : width ,
					url : path ,
					dataSet : this.dataSet
				});
				
			}
			
		}
		
		
	},
	
	/* 撤销操作 */
	cancleClick: function(){
		
		this.dataSet.refresh();
		
	},
	
	editClick: function(){
		
		var isAccess = true;
		
		if(Yacon.isfireuserEvent(this.component.elementID+"_beforeEdit")){
			isAccess = Yacon.fireUserEvent(this.component.elementID+"_beforeEdit", [this.component,this.component.page]);
		}
		
		if(isAccess){
			
			var detail = this.menu.parent.element.detail;
			
			var width = detail.width;
			var height = detail.height;
			var path =  detail.path;
			
			this.dataSet.setAction("type","2");
			
			/* 非弹窗情况支持 */
			if(path == undefined){
					
				this.component.editRow();
				this.component.editRowEvent();
				
			}else{
				
				path = Yacon.addUrlParam("state", "edit", path);
				
				if(!Yacon.isEmpty(detail.param)){
					var params = detail.param;
					for(var i=0;i<params.length;i++){
						
						var paramsKey = params[i].key;
						var foreignKey = params[i].foreign;
						
						if(foreignKey.startsWith("#")){							
							foreignKey = foreignKey.substring(1);					
							path = Yacon.addUrlParam(paramsKey,this.component.page.element.parameter[foreignKey],path);							
						}else{
							path = Yacon.addUrlParam(paramsKey,this.dataSet.getDataSetValue(foreignKey.toUpperCase()),path);							
						}
						
					}
				}
				
				/* 弹窗 */
				Yacon.showModal({
					heigth : height ,
					width : width ,
					url : path ,
					dataSet : this.dataSet
				});
				
			}
			
		}
		
	},
	
	deleteClick: function(){
		
		var isAccess = true;
		
		if(Yacon.isfireuserEvent(this.component.elementID+"_beforeDelete")){
			isAccess = Yacon.fireUserEvent(this.component.elementID+"_beforeDelete", [this.component,this.component.page]);
		}
		
		if(isAccess){
			
			this.dataSet.setAction("type","3");
			
			this.dataSet.getCheckDataSet();
			
			if(this.dataSet.getDataSetCount() <= 0){
				alert("至少选择一条记录！");
				return;
			}
			
			if(window.confirm("确定要进行删除操作吗？")){
				this.dataSet.switchMessage();
			}
			
			var result = this.dataSet.rsp.action.result;
			var msg = this.dataSet.rsp.action.message;
			var type = this.dataSet.rsp.action.type;
			
			this.dataSet.refresh();
			
		}
		
	},
	
	/* 保存  */
	saveClick: function(){
		
		/* 加载数据 */
		this.dataSet.instData();
			
		this.dataSet.switchMessage();
		
		var result = this.dataSet.rsp.action.result;
		var msg = this.dataSet.rsp.action.message;
		var type = this.dataSet.rsp.action.type;
		
		/* 成功 */
		if(result == "0000"){
			
			var isWindowControl = this.element.parent().attr("isWindowControl");
			
			if(!Yacon.isEmpty(isWindowControl) && Yacon.isTrue(isWindowControl)){
				if(this.page.windows){			
					this.page.windows.closeWindow();		
				}
			};
					
			/* 页面刷新 */
			this.dataSet.refresh();
			
		}
		
		
	},
	
	/* 退出 */
	exitClick: function(){	
		
		if(this.page.windows){			
			this.page.windows.closeWindow();		
		}	
	},
	
	/* 刷新 */
	refreshClick: function(){		
		this.dataSet.refresh();	
	},
	
	/* 收缩-伸展 */
	expandClick:function(){
		
		if(this.element.find("span").hasClass("glyphicon-chevron-up")){
			$("#"+this.grid.elementID+" .panel-body").slideDown();	
			$("#"+this.grid.elementID+" .panel-footer").slideDown();
			this.element.find("span").prop("class","glyphicon glyphicon-chevron-down icon");
		}
		else{
			$("#"+this.grid.elementID+" .panel-body").slideUp();	
			$("#"+this.grid.elementID+" .panel-footer").slideUp();
			this.element.find("span").prop("class","glyphicon glyphicon-chevron-up icon");
		}
		
	},
	
	/* 自定义方法 */
	ownerClick: function(){
		var functionName = this.element.attr("view-click");	
		
		if(this.component.elementType == "tsqlgrid"){
			this.component.getDataSet();
		}
		
		Yacon.callBack(functionName, [this.component,this.page,this]);
	},
	
	popShow:function(){
		this.element.popover('show');
	},
	
	popHide:function(){
		this.element.popover('hide');
	},
	
	popToggle:function(){
		this.element.popover('toggle');
	},
	
	popDestroy:function(){
		this.element.popover('destroy');
	}
		
};;
///<jscompress sourcefile="TCheck.js" />
Yacon.widget.TCheck = function(element){
	this.element = element;
};

Yacon.widget.TCheck.prototype = {
	
	/* 获取HTML信息 */
	getHtml: function(){
		
		var html = "";
		
		//标题拼接

		html += "<div class='input-group'>";	
		
		if(this.isEnable() || this.parent.view.isStatic){
			html += "<span class='input-group-btn bk-bg-primary'>";
			html += "<button class='btn bk-bg-primary' type='button'>"+this.element.text+"</button>";
		}else{
			html += "<span class='input-group-btn bk-bg-brown'>";
			html += "<button class='btn bk-bg-brown' type='button'>"+this.element.text+"</button>";
		}
		
		html += "</span>";
		
		html += this.getDataHtml();
		
		html += "</div>";
		
		return html;
		
	},
	
	getDataHtml: function(){
		
		var html = "";
		
		html += "<div style='padding-left:20px;' field-name='"+this.element.name+"' "
		
		html += " class='lily-field' ";
		
		html += " field-type='check' ";
		
		html += ">";
		
		if(!Yacon.isEmpty(this.element.data)){
			
			for(var i=0;i<this.element.data.length;i++){
				
				html += "<label class='checkbox-inline'>";
				
				var active = this.element.data[i];
				
				html += "<input value='"+active.key+"' type='checkbox' ";
				
				html += " field-key='"+active.key+"' field-value='"+active.value+"' ";
				
				if(!this.isEnable()){
					html += " disabled ";
				}
				
				html += this.getDefaultValue(active.key);
				
				html += " >";
				
				html += active.value;
				
				html += "</label>";
				
			}
			
		}
		
		html += "</div>"
		
		return html;
		
	},
	
	getDefaultValue: function(value){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!Yacon.isEmpty(this.element.commonVal)){	
			
			var commVals = this.element.commonVal.split(",");
			
			if(commVals.isExit(value)){
				return "checked";
			}else{
				return "";
			}
		}
		
		else{
			
			if(state == "insert"){
				if(!Yacon.isEmpty(this.element.insertVal)){	
					
					var insertVals = this.element.insertVal.split(",");
					
					if(insertVals.isExit(value)){
						return "checked";
					}else{
						return "";
					}	
				}else{
					return "";
				}
			}
			
			else if(state == "edit"){
				if(!Yacon.isEmpty(this.element.editVal)){
					var editVals = this.element.editVal.split(",");
					if(editVals.isExit(value)){
						return "checked";
					}else{
						return "";
					}
				}else{
					return "";
				}
			}
			
			else {
				return "";
			}
			
		}
	},
	
	isEnable: function(){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!this.element.isEnable){
			return false;
		}
		
		if(state == "insert"){
			return this.element.isInsert;
		}else if(state == "edit"){
			return this.element.isEdit;
		}else if(state == "past"){
			return false;
		}
		else{
			return true;
		}
		
	},
	
	addEvent: function(){
		
	}

};;
///<jscompress sourcefile="TDrop.js" />
Yacon.widget.TDrop = function(element){
	this.element = element;
};

Yacon.widget.TDrop.prototype = {
	/* 获取HTML信息 */	
	getHtml: function(){
		
		var html = "";
			
		html += "<div class='input-group'>";
		
		var lableClass = "";
		
		if(this.isEnable() || this.parent.view.isStatic){
			lableClass += "bk-bg-primary";
		}else{
			lableClass += "bk-bg-brown";
		}
		
		html += "<span class='input-group-btn "+lableClass+"'>";	
		
		html += "<button class='btn "+lableClass+"' type='button'>";
		html += this.element.text;
		html += "</button>";
		
		html += "</span>";
		
		html += "<select name='"+this.element.name+"' class='form-control lily-field' ";
			
		if(this.element.blank){
			html += " placeholder='"+this.element.blank+"' ";
		}
		
		html += " field-name='"+this.element.name+"' ";
		
		html += " field-type='drop' ";
		
		if(!Yacon.isEmpty(this.element.relaID)){
			html += " rela-id='"+this.element.relaID+"' ";
		}
			
		if(!this.isEnable()){
			html += " disabled ";
		}
		
		html += " > ";
		
		/* 选项 */
		var size = this.element.data.length;
		for(var i=0;i<size;i++){
			html += "<option value='"+this.element.data[i].key+"' "+this.getDefaultValue(this.element.data[i].key)+" >"+this.element.data[i].value+"</option>";
		}
		
		if(size != 0){
			this.activeText = this.element.data[0].value;
			this.activeValue = this.element.data[0].key;
		}else{
			
			var relaID = this.element.name;
			var relaObj = this.parent.dropItems.getFieldValue(relaID);
			
			if(!Yacon.isEmpty(relaObj)){
				html += this.addOwnerDrop(relaObj);	
			}
			
		}
		
		html += "</select>";
		
		html += "</div>";
		
		return html;
	},
	
	isEnable: function(){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!this.element.isEnable){
			return false;
		}
		
		if(state == "insert"){
			return this.element.isInsert;
		}else if(state == "edit"){
			return this.element.isEdit;
		}else if(state == "past"){
			return false;
		}	
		else{
			return true;
		}
		
	},
	
	addEvent: function(){
		
		//联动处理
		var relaID = this.element.relaID;
		var elementID = this.element.name.trim().toUpperCase();
		var self = this;
		
		if(!Yacon.isEmpty(relaID)){
			
			$(".form-control.lily-field[field-name='"+elementID.trim().toUpperCase()+"']").unbind("change");
			$(".form-control.lily-field[field-name='"+elementID.trim().toUpperCase()+"']").change(function(){
					
				self.addRelaDrop(self);
				
			});
		}
		
		//校验处理
		
		
	},
	
	getDefaultValue: function(value){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!Yacon.isEmpty(this.element.commonVal)){			
			if(value == this.element.commonVal){
				return "selected";
			}else{
				return "";
			}
		}
		
		else{
			
			if(state == "insert"){
				if(!Yacon.isEmpty(this.element.insertVal)){	
					if(value == this.element.insertVal){
						return "selected";
					}else{
						return "";
					}	
				}else{
					return "";
				}
			}
			
			else if(state == "edit"){
				if(!Yacon.isEmpty(this.element.editVal)){			
					if(value == this.element.editVal){
						return "selected";
					}else{
						return "";
					}
				}else{
					return "";
				}
			}
			
			else {
				return "";
			}
			
		}
	},
	
	addRelaDrop: function(dropObj){
		
		var form = dropObj.parent;
		var relaID = dropObj.element.relaID;
		var relaMethod = dropObj.element.relaMethod;
		var elementID = dropObj.element.name;
		
		var relaDropObj = form.find(relaID);
		
		if(!Yacon.isEmpty(relaID)){
			
			var sendSet = new Yacon.data.DataSet(form.page);
			sendSet.setBody(elementID,form.value(elementID));
			sendSet.switchMessage(relaMethod);
			
			var active = $(".form-control.lily-field[field-name='"+relaID+"']");
			
			active.empty();
			
			var html = "";
			
			while(sendSet.next()){
				
				var fieldText = sendSet.getDataSetValue("text");
				var fieldValue = sendSet.getDataSetValue("value");
				
				html += "<option value='"+fieldValue+"'>"+fieldText+"</option>";
				
			}
			
			active.append(html);
			
			active.find("option").eq(0).prop("selected","true");
			
			this.addRelaDrop(relaDropObj);
			
		}
		
	},
	
	addOwnerDrop: function(dropObj){
				
		var form = dropObj.parent;
		var relaID = dropObj.element.relaID;
		var relaMethod = dropObj.element.relaMethod;
		var elementID = dropObj.element.name;
		
		if(!Yacon.isEmpty(relaID)){
			
			var sendSet = new Yacon.data.DataSet(form.page);
			sendSet.setBody(elementID,dropObj.activeValue);
			sendSet.switchMessage(relaMethod);
			
			var html = "";
			
			var isFirst = true;
			
			while(sendSet.next()){
				
				var fieldText = sendSet.getDataSetValue("text");
				var fieldValue = sendSet.getDataSetValue("value");
				
				if(isFirst){
					this.activeText = fieldText;
					this.activeValue = fieldValue;
					isFirst = false;
				}
				
				html += "<option value='"+fieldValue+"'>"+fieldText+"</option>";
				
			}
			
			return html;
			
		}
		
		return "";
		
	}
	
	
};;
///<jscompress sourcefile="TDropDate.js" />
Yacon.widget.TDropDate = function(element){
	if(element){
		this.element = element;
	}	
};

Yacon.widget.TDropDate.prototype = {
	
	/* 获取HTML信息 */	
	getHtml: function(){
		
		var html = "";
		
		html += this.getDateHtml();
		
		return html;
		
	},
	
	getDateHtml: function(){
		
		var html = "";
		
		if(this.isEnable()){
			
			html += "<div class='input-group date form_date' data-date='' data-date-format='yyyy-mm-dd hh:ii:ss' data-link-format='yyyy-mm-dd hh:ii:ss' ";		
			html += " data-link-field='"+this.element.name+"' ";		
			html += ">";
			
			/* 名称部分 */
			html += "<span class='input-group-btn bk-bg-primary'>";
			html += "<button class='btn bk-bg-primary' type='button'>";
			html += this.element.text;
			html += "</button>";
			html += "</span>";
			
			html += "<input class='form-control lily-fix-field' field-fix-name='"+this.element.name+"' size='16' type='text' value='' readonly/>";
			html += "<span class='input-group-addon'><span class='glyphicon glyphicon-remove'></span></span>";
			html += "<span class='input-group-addon'><span class='glyphicon glyphicon-calendar'></span></span>";
			html += "<input class='lily-field' name='"+this.element.name+"' field-name='"+this.element.name+"' type='hidden' id='"+this.element.name+"' value='' />";
			
			html += "</div>";

			
		}else{
			
			html += this.getDisableHtml();
			
		}
		
		
		return html;
		
	},
	
	getTimeHtml: function(){
		
		var html = "";
		
		if(this.isEnable()){
			
			html += "<div class='input-group date form_time' data-date='' data-date-format='hh:ii:ss' data-link-format='hh:ii:ss' ";		
			html += " data-link-field='"+this.element.name+"' ";		
			html += ">";
			
			/* 名称部分 */
			html += "<span class='input-group-btn bk-bg-primary'>";
			html += "<button class='btn bk-bg-primary' type='button'>";
			html += this.element.text;
			html += "</button>";
			html += "</span>";
			
			html += "<input class='form-control lily-fix-field' field-fix-name='"+this.element.name+"' size='16' type='text' value='' readonly/>";
			html += "<span class='input-group-addon'><span class='glyphicon glyphicon-remove'></span></span>";
			html += "<span class='input-group-addon'><span class='glyphicon glyphicon-time'></span></span>";
			html += "<input class='lily-field' name='"+this.element.name+"' field-name='"+this.element.name+"' type='hidden' id='"+this.element.name+"' value='' />";
			
			html += "</div>";
			
		}
		else{
			
			html += this.getDisableHtml();
			
		}
			
		return html;
		
	},
	
	getDateTimeHtml: function(){
		
		var html = "";
		
		if(this.isEnable()){
			
			html += "<div class='input-group date form_datetime' data-date='1979-09-16T05:25:07Z' data-date-format='yyyy-mm-dd hh:ii:ss'  ";		
			html += " data-link-field='"+this.element.name+"' ";		
			html += ">";
			
			/* 名称部分 */
			html += "<span class='input-group-btn bk-bg-primary'>";
			html += "<button class='btn bk-bg-primary' type='button'>";
			html += this.element.text;
			html += "</button>";
			html += "</span>";
			
			html += "<input class='form-control lily-fix-field' field-fix-name='"+this.element.name+"' size='16' type='text' value='' readonly/>";
			html += "<span class='input-group-addon'><span class='glyphicon glyphicon-remove'></span></span>";
			html += "<span class='input-group-addon'><span class='glyphicon glyphicon-th'></span></span>";
			html += "<input class='lily-field' name='"+this.element.name+"' field-name='"+this.element.name+"' type='hidden' id='"+this.element.name+"' value='' />";
			
			html += "</div>";
			
		}else{
			html += this.getDisableHtml();
		}
		
		return html;
		
	},
	
	getTimestampHtml: function(){
		
		var html = "";
		
		if(this.isEnable()){
			
			html += "<div class='input-group date form_datetime' data-date='1979-09-16T05:25:07Z' data-date-format='yyyy-mm-dd hh:ii:ss'  ";		
			html += " data-link-field='"+this.element.name+"' ";		
			html += ">";
			
			/* 名称部分 */
			html += "<span class='input-group-btn bk-bg-primary'>";
			html += "<button class='btn bk-bg-primary' type='button'>";
			html += this.element.text;
			html += "</button>";
			html += "</span>";
			
			html += "<input class='form-control lily-fix-field' field-fix-name='"+this.element.name+"' size='16' type='text' value='' readonly/>";
			html += "<span class='input-group-addon'><span class='glyphicon glyphicon-remove'></span></span>";
			html += "<span class='input-group-addon'><span class='glyphicon glyphicon-th'></span></span>";
			html += "<input class='lily-field' name='"+this.element.name+"' field-name='"+this.element.name+"' type='hidden' id='"+this.element.name+"' value='' />";
			
			html += "</div>";

		}
		
		else{
			
			html += this.getDisableHtml();
			
		}
		
		return html;
		
	},
	
	getDisableHtml: function(){
		
		var html = "";
			
		html += "<div class='input-group'>";
		
		if(this.parent.view.isStatic){
			html += "<span class='input-group-btn bk-bg-primary'>";	
			html += "<button class='btn bk-bg-primary' type='button'>";
		}else{
			html += "<span class='input-group-btn bk-bg-brown'>";	
			html += "<button class='btn bk-bg-brown' type='button'>";
		}
		
		html += this.element.text;
		html += "</button>";
		html += "</span>";
		
		html += "<input ";
		
		html += " id='"+this.element.name+"' ";
		html += " class='form-control lily-field' name='"+this.element.name+"' type='text' ";
		
		html += " field-name='"+this.element.name+"' ";
		
		if(this.element.blank){
			html += " placeholder='"+this.element.blank+"' ";
		}
			
		html += " disabled ";
			
		html += " />";
		
		html += "</div>";
		
		return html;
		
	},
	
	addEvent: function(){
		
		$('.form_datetime').datetimepicker({
	        language:  'zh-CN',
	        weekStart: 1,
	        todayBtn:  1,
			autoclose: 1,
			todayHighlight: 1,
			startView: 2,
			forceParse: 0,
	        showMeridian: 1
	    });
		$('.form_date').datetimepicker({
	        language:  'zh-CN',
	        weekStart: 1,
	        todayBtn:  1,
			autoclose: 1,
			todayHighlight: 1,
			startView: 2,
			minView: 2,
			forceParse: 0
	    });
		$('.form_time').datetimepicker({
	        language:  'zh-CN',
	        weekStart: 1,
	        todayBtn:  1,
			autoclose: 1,
			todayHighlight: 1,
			startView: 1,
			minView: 0,
			maxView: 1,
			forceParse: 0
	    });
		
	},
	
	isEnable: function(){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!this.element.isEnable){
			return false;
		}
		
		if(state == "insert"){
			return this.element.isInsert;
		}else if(state == "edit"){
			return this.element.isEdit;
		}else if(state == "past"){
			return false;
		}
		else{
			return true;
		}
		
	}

};;
///<jscompress sourcefile="TInput.js" />
Yacon.widget.TInput = function(element){
	this.element = element;
};

Yacon.widget.TInput.prototype = {
	
	/* 获取HTML信息 */	
	getHtml: function(){	
		
		var html = "";
		
		html += "<div class='input-group'>";
		
		var lableClass = "";
		
		if(this.isEnable() || this.parent.view.isStatic){
			lableClass += "bk-bg-primary";
		}else{
			lableClass += "bk-bg-brown";
		}
		
		html += "<span class='input-group-btn "+lableClass+"'>";
		
		html += "<button class='btn "+lableClass+"' type='button'>";
		html += this.element.text;
		html += "</button>";
		html += "</span>";
		
		html += "<input ";
		
		html += " id='"+this.element.name+"' ";
		html += " class='form-control lily-field' name='"+this.element.name+"' type='text' ";
		
		html += " field-name='"+this.element.name+"' ";
		
		html += " field-type='input' ";
		
		if(this.element.blank){
			html += " placeholder='"+this.element.blank+"' ";
		}
		
		if(!this.isEnable()){
			html += " disabled ";
		}
		
		html += this.getDefaultValue();
		
		html += " />";
		
		html += "</div>";
		
		return html;
	},
	
	isEnable: function(){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!this.element.isEnable){
			return false;
		}
		
		if(state == "insert"){
			return this.element.isInsert;
		}else if(state == "edit"){
			return this.element.isEdit;
		}else if(state == "past"){
			return false;
		}
		else{
			return true;
		}
		
	},
	
	getDefaultValue: function(){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!Yacon.isEmpty(this.element.commonVal)){			
			return " value='"+this.element.commonVal+"' ";		
		}
		
		else{
			
			if(state == "insert"){
				if(!Yacon.isEmpty(this.element.insertVal)){			
					return " value='"+this.element.insertVal+"' ";		
				}else{
					return "";
				}
			}
			
			else if(state == "edit"){
				if(!Yacon.isEmpty(this.element.editVal)){			
					return " value='"+this.element.editVal+"' ";	
				}else{
					return "";
				}
			}
			
			else {
				return "";
			}
			
		}
	},
	
	addEvent: function(){
		
		var success = "<span class='glyphicon glyphicon-ok form-control-feedback'></span>";
		var error = "<span class='glyphicon glyphicon-remove form-control-feedback'></span>";
		var warning = "<span class='glyphicon glyphicon-warning-sign form-control-feedback'></span>";
		var self = this;
		
		if(Yacon.isTrue(this.element.isCheck)){
			
			$(".form-control.lily-field[field-name='"+this.element.name+"']").unbind("blur");
			$(".form-control.lily-field[field-name='"+this.element.name+"']").blur(function(){
				
				var parDiv = $(this).parent();
				if(!parDiv.hasClass("has-feedback")){
					parDiv.addClass("has-feedback");
				}
				
				var activeVal = $(this).val();
				
				if(!Yacon.isTrue(self.element.isNull)){
					
					if(activeVal.trim() == ""){				
						parDiv.addClass("has-error");
						$(this).after(error);				
						return;
					}
				}
				else{
					parDiv.addClass("has-success");
					$(this).after(success);	
				}
				
			});
			
			$(".form-control.lily-field[field-name='"+this.element.name+"']").unbind("focus");
			$(".form-control.lily-field[field-name='"+this.element.name+"']").focus(function(){
				
				var parDiv = $(this).parent();
				
				parDiv.removeClass("has-feedback");
				parDiv.removeClass("has-success");
				parDiv.removeClass("has-error");
				parDiv.removeClass("has-warning");
				
				$(this).parent().find(".glyphicon.glyphicon-ok.form-control-feedback").remove();
				$(this).parent().find(".glyphicon.glyphicon-remove.form-control-feedback").remove();
				$(this).parent().find(".glyphicon.glyphicon-warning-sign.form-control-feedback").remove();
				
				
			});
			
		}
		
	}

};;
///<jscompress sourcefile="TLabel.js" />
Yacon.widget.TLabel = function(element){
	this.element = element;
};

Yacon.widget.TLabel.prototype = {
	
	/* 获取HTML信息 */
	getHtml: function(){
		
		var html = "";
		
		//标题拼接
		html += "<div class='input-group'>";	
		
		if(this.isEnable() || this.parent.view.isStatic){
			html += "<span class='input-group-btn bk-bg-primary'>";
			html += "<button class='btn bk-bg-primary' type='button'>"+this.element.text+"</button>";
		}else{
			html += "<span class='input-group-btn bk-bg-brown'>";
			html += "<button class='btn bk-bg-brown' type='button'>"+this.element.text+"</button>";
		}
		
		html += "</span>";
		
		html += this.getDataHtml();
		
		html += "</div>";
		
		return html;
		
	},
	
	getDataHtml: function(){
		
		var html = "";
		
		html += "<div style='padding-left:20px;padding-top:2px;padding-bottom:2px;' field-name='"+this.element.name+"' "
		
		html += ">";
		
		/* 展示信息 */
		html += "<span ";
		
		html += " field-name='"+this.element.name+"' "
			
		html += " class='lily-field' ";
		
		html += " field-type='label' ";
		
		html += " >";
		
		html += this.getDefaultValue();
		
		html += "</span>";
		
		html += "</div>"
		
		return html;
		
	},
	
	isEnable: function(){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!this.element.isEnable){
			return false;
		}
		
		if(state == "insert"){
			return this.element.isInsert;
		}else if(state == "edit"){
			return this.element.isEdit;
		}else if(state == "past"){
			return false;
		}
		else{
			return true;
		}
		
	},
	
	getDefaultValue: function(){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!Yacon.isEmpty(this.element.commonVal)){			
			return this.element.commonVal;		
		}
		
		else{
			
			if(state == "insert"){
				if(!Yacon.isEmpty(this.element.insertVal)){			
					return this.element.insertVal;		
				}else{
					return "";
				}
			}
			
			else if(state == "edit"){
				if(!Yacon.isEmpty(this.element.editVal)){			
					return this.element.editVal;	
				}else{
					return "";
				}
			}
			
			else {
				return "";
			}
			
		}
	},
	
	addEvent: function(){
		
	}

};;
///<jscompress sourcefile="TProgress.js" />
Yacon.widget.TProgress = function(element){
	this.element = element;
};

Yacon.widget.TProgress.prototype = {
	
	/* 获取HTML信息  */	
	getHtml: function(){
		
		var html = "";
		
		//标题拼接
		html += "<div class='input-group'>";	
		
		html += "<span class='input-group-btn bk-bg-primary'>";
		html += "<button class='btn bk-bg-primary' type='button'>"+this.element.text+"</button>";
		
		
		html += "</span>";
		
		html += this.getDataHtml();
		
		html += "</div>";
		
		return html;
		
		
	},
	
	
	getDataHtml: function(){
		
		var html = "";
		
		html += "<div style='padding-left:20px;padding-top:2px;padding-bottom:2px;' field-name='"+this.element.name+"' "
		
		html += ">";
		
		html += "<div class='progress' style='margin-bottom:0px;'>";
		
		html += "<div ";
		
		var className = "progress-bar";
		
		if(!Yacon.isEmpty(this.element.proType)){
			className += " progress-bar-"+this.element.proType;
		}
		
		if(Yacon.isTrue(this.element.isLine)){
			className += " progress-bar-striped";
		}
		
		if(Yacon.isTrue(this.element.isActive)){
			className += " active";
		}
		
		className += " lily-field";
		
		html += " class='"+className+"' ";
		html += " role='progressbar' ";
		html += " aria-valuenow='"+this.element.proWidth+"' ";
		html += " aria-valuemin='"+this.element.proMin+"' ";
		html += " aria-valuemax='"+this.element.proMax+"' ";
		html += " style='width: "+this.element.proWidth+"%;min-width: 2em;' ";
		
		html += " field-name='"+this.element.name+"'";
		
		html += " field-type='progress'";
		
		html += " >";
		
		if(Yacon.isTrue(this.element.isPerShow)){
			html += this.element.proWidth+"%";
		}
			
		html += "</div>";
		
		html += "</div>";
		
		/* 展示信息 */
		/*html += "<span ";
		
		html += " field-name='"+this.element.name+"' "
			
		html += " class='lily-field' ";
		
		html += " field-type='progress' ";
		
		html += " >";
		
		html += "";
		
		html += "</span>";*/
		
		html += "</div>"
		
		return html;
		
	}
		
};;
///<jscompress sourcefile="TRadio.js" />
Yacon.widget.TRadio = function(element){
	this.element = element;
};

Yacon.widget.TRadio.prototype = {
		
	/* 获取HTML信息 */
	getHtml: function(){
		
		var html = "";
		
		//标题拼接

		html += "<div class='input-group'>";
		
		if(this.isEnable() || this.parent.view.isStatic){
			html += "<span class='input-group-btn bk-bg-primary'>";
			html += "<button class='btn bk-bg-primary' type='button'>"+this.element.text+"</button>";
		}else{
			html += "<span class='input-group-btn bk-bg-brown'>";
			html += "<button class='btn bk-bg-brown' type='button'>"+this.element.text+"</button>";
		}
		
		html += "</span>";
		
		html += this.getDataHtml();
		
		html += "</div>";
		
		return html;
		
	},
	
	getDataHtml: function(){
		
		var html = "";
		
		html += "<div style='padding-left:20px;' field-name='"+this.element.name+"' "
		
		html += " class='lily-field' ";
		
		html += " field-type='radio' ";
		
		html += ">";
		
		if(!Yacon.isEmpty(this.element.data)){
			
			for(var i=0;i<this.element.data.length;i++){
				
				html += "<label class='radio-inline'>";
				
				var active = this.element.data[i];
				
				html += "<input value='"+active.key+"' type='radio' ";
				
				html += " field-key='"+active.key+"' field-value='"+active.value+"' ";
				
				html += " name='"+this.element.name+"' ";
				
				if(!this.isEnable()){
					html += " disabled ";
				}
				
				html += this.getDefaultValue(active.key);
				
				html += " >";
				
				html += active.value;
				
				html += "</label>";
				
			}
			
		}
		
		html += "</div>"
		
		return html;
		
	},
	
	getDefaultValue: function(value){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!Yacon.isEmpty(this.element.commonVal)){	
					
			if(this.element.commonVal == value){
				return "checked";
			}else{
				return "";
			}
		}
		
		else{
			
			if(state == "insert"){
				if(!Yacon.isEmpty(this.element.insertVal)){	
					
					if(this.element.insertVal == value){
						return "checked";
					}else{
						return "";
					}	
				}else{
					return "";
				}
			}
			
			else if(state == "edit"){
				if(!Yacon.isEmpty(this.element.editVal)){
					
					if(this.element.editVal == value){
						return "checked";
					}else{
						return "";
					}
					
				}else{
					return "";
				}
			}
			
			else {
				return "";
			}
			
		}
	},
	
	isEnable: function(){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!this.element.isEnable){
			return false;
		}
		
		if(state == "insert"){
			return this.element.isInsert;
		}else if(state == "edit"){
			return this.element.isEdit;
		}else if(state == "past"){
			return false;
		}
		else{
			return true;
		}
		
	},
	
	addEvent: function(){
		
	}	
};;
///<jscompress sourcefile="TTextArea.js" />
Yacon.widget.TTextArea = function(element){
	this.element = element;
};

Yacon.widget.TTextArea.prototype = {
	
	/* 获取HTML信息 */	
	getHtml: function(){	
		var html = "";
		
		html += "<div class='input-group'>";
		
		var lableClass = "";
		
		if(this.isEnable() || this.parent.view.isStatic){
			lableClass += "bk-bg-primary";
		}else{
			lableClass += "bk-bg-brown";
		}
		
		html += "<span class='input-group-btn "+lableClass+"'>";
		
		html += "<button class='btn "+lableClass+"' type='button'>";
		html += this.element.text;
		html += "</button>";
		
		html += "<textarea ";
		
		html += " class='form-control lily-field' ";
		html += " rows='"+this.element.span+"' ";
		html += " id='"+this.element.name+"' ";
		
		if(this.element.blank){
			html += " placeholder='"+this.element.blank+"' ";
		}
		
		html += " field-name='"+this.element.name+"' ";
		html += " field-type='textarea' ";
		
		if(!this.isEnable()){
			html += " disabled ";
		}	
		
		html += " >";
		
		html += this.getDefaultValue();
		
		html += "</textarea>"
			
		html += "</span>";
		
		html += "</div>";
		
		return html;
	},
	
	isEnable: function(){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!this.element.isEnable){
			return false;
		}
		
		if(state == "insert"){
			return this.element.isInsert;
		}else if(state == "edit"){
			return this.element.isEdit;
		}else if(state == "past"){
			return false;
		}
		else{
			return true;
		}
		
	},
	
	getDefaultValue: function(){
		
		this.page = this.parent.page;
		var state = this.page.element.parameter.state;
		
		if(Yacon.isEmpty(state)){
			state = "active";
		}
		
		if(!Yacon.isEmpty(this.element.commonVal)){			
			return this.element.commonVal;		
		}
		
		else{
			
			if(state == "insert"){
				if(!Yacon.isEmpty(this.element.insertVal)){			
					return this.element.insertVal;
				}else{
					return "";
				}
			}
			
			else if(state == "edit"){
				if(!Yacon.isEmpty(this.element.editVal)){			
					return this.element.editVal;		
				}else{
					return "";
				}
			}
			
			else {
				return "";
			}
			
		}
	},
	
	addEvent: function(){
		
	}

};;
///<jscompress sourcefile="TTree.js" />
Yacon.component.TTree = function(conText){
	
	Yacon.apply(this,conText);
	
	this.baseCreate();
	
};

Yacon.component.TTree.prototype = {
	
	baseCreate: function(){
		
		this.elementID = this.view.id;
		this.elementType = this.view.type;	
		
		this.dataSet = new Yacon.data.DataSet(this.page);
		this.dataSet.component = this;
		this.dataSet.elementID = this.elementID;
		this.dataSet.defaultMethod = this.view.excute;
		this.dataSet.refreshMethod = this.view.refresh;
		this.dataSet.setBody("treeParID",this.view.parId);
		this.dataSet.setBody("treeNowID",this.view.nowId);
		this.dataSet.setBody("treeNowName",this.view.nowName);
		this.dataSet.setBody("treeChildID",this.view.child);
		
		this.newCount = 1;
	},	
		
	getHtml: function(){
		
		var html = "";
		
		html += "<div style='overflow:auto; height:100%; width:100%;'>";
		
		html += "<div id='"+this.view.id+"' ";	
		
		html += " lily-id='"+this.view.id+"' lily-type='tree' ";
		
		html += " style='padding-bottom:15px;'>";
		
		html += "<ul id='"+this.view.id+"_Tree' class='ztree'></ul>";
		
		html += "</div>";
		
		html += "</div>";
		
		return html;
		
	},
	
	/* 事件装载  */
	addEvents: function(){		
		this.loadTree();	
	},
	
	/* 树装载 */
	loadTree: function(){
		
		this.treeId = this.elementID+"_Tree";
		
		this.isEdit = this.view.isEdit;
		
		if(this.isEdit){
			
			this.setting = {
					
					data: {
						simpleData: {
							enable: true
						}
					},
					view: {
						addHoverDom: addHoverDom,
						removeHoverDom: removeHoverDom
					},
					async: {
						enable: true,
						url: zTreeUrl
					},
						
					edit:{
						enable:this.isEdit,
						removeTitle: "删除",
						renameTitle: "修改",
						showRemoveBtn: showRemoveBtn,
						showRenameBtn: showRenameBtn
					},
					
					callback: {
						beforeRemove: zTreeBeforeRemove,
						onRemove: zTreeAfterRemove,
						beforeRename: zTreeBeforeRename,
						onRename: zTreeAfterRename,
						beforeEditName: zTreeBeforeEditName,
						onClick: zTreeOnClick,
						onAsyncSuccess: zTreeAfterRefresh,
						beforeAsync: zTreeBeforeRefresh
					},
					
					lilyTree:this
					
				};
			
		}
		
		else{
			
			this.setting = {
					
				data: {
					simpleData: {
						enable: true
					}
				},
				async: {
					enable: true,
					url: zTreeUrl
				},
				
				callback: {
					onClick: zTreeOnClick
				},
				
				lilyTree:this
				
			};
			
		}
		
		if(this.view.choice == "check"){
			this.setting.check = {
				enable: true
			}
		}
		
		else if(this.view.choice == "radio"){
			this.setting.check = {
				enable: true,
				chkStyle: "radio",
				radioType: this.view.radio
			}
		}
		
		this.rootID = this.view.rootId;
		this.rootName = this.view.rootName;
			
		this.zNodes =[
     		{ 
     		  name:this.rootName,
     		  isParent:true , 
     		  nodeID:this.rootID, 
     		  nodeName:this.rootName, 
              parentID:-1
     		}
     	];
		
		var self = this;
		
		$(document).ready(function(){
			$.fn.zTree.init($("#"+self.treeId), self.setting, self.zNodes);
					
			//选中并展开一个节点
			var treeObj = $.fn.zTree.getZTreeObj(self.treeId);
			var nodes = treeObj.getNodes();
			if (nodes.length>0) {
				
				if(self.view.expandMode == "first"){
					treeObj.reAsyncChildNodes(nodes[0], "refresh");
				}
				
				if(self.view.clickMode == "root"){
					
					treeObj.selectNode(nodes[0]);	
					
					if(!Yacon.isEmpty(nodes[0].click)){
						nodes[0].click();
					}
					
				}
				
			}
			
		});
		
	},
	
	/* 重置树信息 */
	resetTree: function(treeId, treeNode){
		this.treeId = treeId;
		this.treeNode = treeNode;	
		this.dataSet.setBody("treeLevel",this.treeNode.level);
		this.dataSet.setBody(this.view.parId,this.treeNode.nodeID);	
	},
	
	/* 刷新树 */
	refresh:function(treeId, treeNode){
		
		if(!Yacon.isEmpty(treeId) && !Yacon.isEmpty(treeNode)){
			this.resetTree(treeId, treeNode);
		}else if(!Yacon.isEmpty(this.activeTreeId) && !Yacon.isEmpty(this.activeTreeNode)){
			this.resetTree(this.activeTreeId, this.activeTreeNode);
		}
				
		this.dataSet.setAction("methodType","treeRefresh");
		this.dataSet.setAction("methodName",this.dataSet.refreshMethod);
		return this.dataSet.getUrl();
	},
	
	refreshParent: function(treeId, treeNode){
		
		this.resetTree(treeId, treeNode);
		
		if(!Yacon.isEmpty(this.activeTreeId) && !Yacon.isEmpty(this.activeTreeNode)){
			this.resetTree(this.activeTreeId, this.activeTreeNode);
		}
		
		var node = this.treeNode.getParentNode();		
		var treeObj = $.fn.zTree.getZTreeObj(this.treeId);
		treeObj.reAsyncChildNodes(node, "refresh");
		
	},
	
	refreshActive: function(treeId, treeNode){
		
		this.resetTree(treeId, treeNode);
		
		if(!Yacon.isEmpty(this.activeTreeId) && !Yacon.isEmpty(this.activeTreeNode)){
			this.resetTree(this.activeTreeId, this.activeTreeNode);
		}
		
		var treeObj = $.fn.zTree.getZTreeObj(this.treeId);
		
		treeObj.reAsyncChildNodes(this.treeNode, "refresh");
		
	},
	
	refreshActiveAuto: function(treeId,treeNode){
		
		this.startFlag = "auto";
		
		this.resetTree(treeId, treeNode);
		
		if(!Yacon.isEmpty(this.activeTreeId) && !Yacon.isEmpty(this.activeTreeNode)){
			this.resetTree(this.activeTreeId, this.activeTreeNode);
		}
		
		var treeObj = $.fn.zTree.getZTreeObj(this.treeId);
		
		treeObj.reAsyncChildNodes(this.treeNode, "refresh");
		
	},
	
	/* 树展示 */
	show:function(treeId,treeNode,type){
		
		this.activeTreeId = treeId;
		this.activeTreeNode = treeNode;
		
		this.resetTree(treeId, treeNode);
		
		/*treeNode.click();*/
		
		if(Yacon.isfireuserEvent(this.elementID+"_show")){
			return Yacon.fireUserEvent(this.elementID+"_show", [this,this.page,type]);
		}	
		return true;	
	},
	
	/* 增加前 */
	beforeAdd: function(treeId,treeNode){
		
		this.resetTree(treeId, treeNode);
		
		if(Yacon.isfireuserEvent(this.elementID+"_beforeEdit")){
			return Yacon.fireUserEvent(this.elementID+"_beforeEdit", [this,this.page]);
		}
		
		return true;
		
	},
	
	addNode:function(treeId, treeNode, newName, isCancel){
		
		this.resetTree(treeId,treeNode);
		
		if(this.beforeAdd(treeId, treeNode)){
			
			this.dataSet.setBody("treeLevel",this.treeNode.getParentNode().level);
			this.dataSet.setBody(this.view.parId,this.treeNode.getParentNode().nodeID);	
			
			this.dataSet.setAction("methodName",this.dataSet.defaultMethod);
			this.dataSet.setAction("methodType","treeExcute");
			this.dataSet.setAction("type","1");
			this.dataSet.setDataSet(this.view.nowName,newName);
			
			this.dataSet.switchMessage();
			
			var result = this.dataSet.rsp.action.result;
			var msg = this.dataSet.rsp.action.message;
			var type = this.dataSet.rsp.action.type;
			
			if(result == "0000"){
							
				treeNode.nodeName = newName;				
				this.refreshParent(treeId,treeNode);				
				return true;
				
			}else{							
				return false;
			}
			
		}
		
		this.afterAdd(treeId, treeNode);
		
	},
	
	/* 增加后处理 */
	afterAdd: function(treeId,treeNode){
		
		this.resetTree(treeId, treeNode);
		
		if(Yacon.isfireuserEvent(this.elementID+"_afterAdd")){
			return Yacon.fireUserEvent(this.elementID+"_afterAdd", [this,this.page]);
		}
		
		return true;
		
	},
	
	/* 修改前处理 */
	beforeEdit: function(treeId,treeNode){
		
		this.resetTree(treeId, treeNode);
		
		if(Yacon.isfireuserEvent(this.elementID+"_beforeEdit")){
			return Yacon.fireUserEvent(this.elementID+"_beforeEdit", [this,this.page]);
		}
		
		return true;
		
	},
	
	/* 修改 */
	editNode:function(treeId, treeNode, newName, isCancel){
		
		if(this.beforeEdit(treeId, treeNode)){
			
			this.resetTree(treeId, treeNode);
			
			this.dataSet.setAction("methodName",this.dataSet.defaultMethod);
			this.dataSet.setAction("methodType","treeExcute");
			this.dataSet.setAction("type","2");
			
			/* 节点非空 */
			if(!Yacon.isEmpty(treeNode.dataSet)){
				
				for(var prp in treeNode.dataSet){
					this.dataSet.setDataSet(prp,treeNode.dataSet[prp].fieldvalue,treeNode.dataSet[prp].fieldoldvalue);
				}
				
			}
			
			this.dataSet.getFieldValue(this.view.nowName).setFieldValue("fieldvalue",newName);
			
			this.dataSet.switchMessage();
			
			var result = this.dataSet.rsp.action.result;
			var msg = this.dataSet.rsp.action.message;
			var type = this.dataSet.rsp.action.type;
			
			if(result == "0000"){			
				
				//刷新
				this.refreshParent(treeId, treeNode);
				
				return true;
				
			}else{				
				return false;
			}
			
		}
		
		this.afterEdit(treeId, treeNode);
		
	},
	
	/* 修改后处理 */
	afterEdit: function(treeId,treeNode){
		
		this.resetTree(treeId, treeNode);
		
		if(Yacon.isfireuserEvent(this.elementID+"_afterEdit")){
			return Yacon.fireUserEvent(this.elementID+"_afterEdit", [this,this.page]);
		}
		
		return true;
		
	},
	
	/* 删除前处理 */
	beforeDelete: function(treeId, treeNode){
		
		this.resetTree(treeId, treeNode);
		
		if(Yacon.isfireuserEvent(this.elementID+"_beforeDelete")){
			return Yacon.fireUserEvent(this.elementID+"_beforeDelete", [this,this.page]);
		}
		
		return true;
	},
	
	/* 删除处理 */
	deleteNode:function(treeId, treeNode){
		
		if(this.beforeDelete(treeId, treeNode)){
			
			if(!window.confirm("确定要删除数据吗？")){
				return false;
			}
			
			this.resetTree(treeId, treeNode);
			
			this.dataSet.setAction("methodName",this.dataSet.defaultMethod);
			this.dataSet.setAction("methodType","treeExcute");
			this.dataSet.setAction("type","3");
			
			/* 节点非空 */
			if(!Yacon.isEmpty(treeNode.dataSet)){			
				for(var prp in treeNode.dataSet){
					this.dataSet.setDataSet(prp,treeNode.dataSet[prp].fieldvalue,treeNode.dataSet[prp].fieldoldvalue);
				}			
			}
			
			this.dataSet.switchMessage();
			
			var result = this.dataSet.rsp.action.result;
			var msg = this.dataSet.rsp.action.message;
			var type = this.dataSet.rsp.action.type;
			
			if(result == "0000"){		
				return true;
			}else{					
				return false;
			}
			
		}
		
		return false;
		
	},
	
	/* 删除后处理 */
	afterDelete: function(treeId, treeNode){
		
		this.resetTree(treeId, treeNode);
		
		this.refreshParent(treeId, treeNode);
		
		if(Yacon.isfireuserEvent(this.elementID+"_afterDelete")){
			return Yacon.fireUserEvent(this.elementID+"_afterDelete", [this,this.page]);
		}
		
		return true;
	},
	
	/* 修改名称 - 增加、修改都预先走该部分 */
	editName: function(treeId, treeNode){
		
		this.resetTree(treeId, treeNode);
		
		var element = "";
		
		if(Yacon.isfireuserEvent(this.elementID+"_page")){
			element = Yacon.fireUserEvent(this.elementID+"_page", [this,this.page]);
		}
		
		if(Yacon.isEmpty(element)){
			return true;
		}else{
						
			this.dataSet.setAction("methodName",this.dataSet.defaultMethod);
			this.dataSet.setAction("methodType","treeExcute");
			
			if(treeNode.nodeTyp == "add"){
				this.dataSet.setAction("type","1");
				this.dataSet.setBody(this.view.parId,treeNode.getParentNode().nodeID);
			}else{
				this.dataSet.setAction("type","2");		
				this.dataSet.setBody(this.view.parId,treeNode.nodeID);
			}
			
			if(!Yacon.isEmpty(treeNode.dataSet)){
				
				for(var prp in treeNode.dataSet){
					this.dataSet.setDataSet(prp,treeNode.dataSet[prp].fieldvalue,treeNode.dataSet[prp].fieldoldvalue);
				}
				
			}
			
			if(treeNode.nodeTyp == "add"){
				
				var url = Yacon.addUrlParam("state", "insert", element.url);
				
				Yacon.showModal({
					width: element.width ,
					height: element.height ,
					url : url ,
					dataSet : this.dataSet,
					close:{
						method:"zTreeRefreshActiveAuto",
						param:[this,this.page]
					}
				});
				
			}else{
				
				var url = Yacon.addUrlParam("state", "edit", element.url);
				
				Yacon.showModal({
					width: element.width ,
					height: element.height ,
					url : url ,
					dataSet : this.dataSet,
					close:{
						method:"zTreeRefresh",
						param:[this,this.page]
					}
				});
				
			}
			
			return false;
			
		}
		
	},
	
	/* 添加按钮控制 */
	addDom:function(treeId, treeNode){
		
		this.resetTree(treeId, treeNode);
		
		var sObj = $("#" + treeNode.tId + "_span");
		
		var isShow = true;
		
		isShow = this.show(treeId, treeNode,"add");
		
		var self = this;
		
		if(isShow){
			
			if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
			var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
				+ "' title='增加' onfocus='this.blur();'></span>";
			sObj.after(addStr);
			var btn = $("#addBtn_"+treeNode.tId);
			if (btn) btn.bind("click", function(){
				var zTree = $.fn.zTree.getZTreeObj(treeId);
				
				var active = zTree.addNodes(treeNode, {pId:treeNode.id,nodeTyp:"add", name:"new node" + (self.newCount++),dataSet:[]});
				
				if(zTreeBeforeEditName(treeId,active[0])){
					zTree.editName(active[0]);
				}	
				
				return false;
			});
			
		}
		
	},
	
	/* 初始化数据 - 与Grid 重复 */
	instData: function(){
		
		var typ = this.dataSet.getAction("type");		

		if(typ == "1"){
			this.insertDataSet();
		}
		
		else if(typ == "2"){
			this.editDataSet();
		}
		
		else if(typ == "3"){
			
		}
		
		return true;

	},
	
	/* 初始化数据 - 与Grid 重复 */
	insertDataSet: function(){
			
		var alls;
		
		this.control = "#"+this.elementID+"_window ";
		
		if(this.control){			
			alls = $(this.control+" .lily-field");		
		}else{
			alls = $(".lily-field");
		}
		
		if(alls){
			
			var size = alls.length;	
			this.dataSet.getFirstRecord();	
			
			for(var i=0;i<size;i++){
			
				var active = alls.eq(i);
				var fieldName = active.attr("field-name");
				var fieldValue = active.val();
				
				if(Yacon.isNull(fieldValue)){
					fieldValue = "";
				}
				
				//复选框
				var fieldTyp = active.attr("field-type");
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "check"){
					var allChecks = active.find("input[type='checkbox']:checked");
					for(var j=0;j<allChecks.length;j++){
						fieldValue += ","+allChecks.eq(j).attr("field-key") ;
					}
					
					if(fieldValue.startsWith(",")){
						fieldValue = fieldValue.substring(1);
					}
					
				}
				
				//单选框
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "radio"){
					var allChecks = active.find("input[type='radio']:checked");
					for(var j=0;j<allChecks.length;j++){
						fieldValue += ","+allChecks.eq(j).attr("field-key") ;
					}
					
					if(fieldValue.startsWith(",")){
						fieldValue = fieldValue.substring(1);
					}
					
				}
				
				//Label信息
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "label"){
					fieldValue = active.html();
				}
				
				var fieldOldValue = fieldValue;
				
				this.dataSet.setDataSet(fieldName,fieldValue,fieldOldValue);
				
			}
			
		}
		
	},
	
	/* 初始化数据 - 与Grid 重复 */
	editDataSet: function(){
		
		var alls;
		
		if(this.control){			
			alls = $(this.control+" .lily-field");		
		}else{
			alls = $(".lily-field");
		}
		
		if(alls){
			
			var size = alls.length;	
			this.dataSet.getFirstRecord();	
			
			for(var i=0;i<size;i++){
			
				var active = alls.eq(i);
				var fieldName = active.attr("field-name");
				var fieldValue = active.val();
				
				if(Yacon.isNull(fieldValue)){
					fieldValue = "";
				}
				
				//复选框
				var fieldTyp = active.attr("field-type");
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "check"){
					var allChecks = active.find("input[type='checkbox']:checked");
					
					for(var j=0;j<allChecks.length;j++){
						fieldValue += ","+allChecks.eq(j).attr("field-key") ;
					}
					
					if(fieldValue.startsWith(",")){
						fieldValue = fieldValue.substring(1);
					}
				}
				
				//单选框
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "radio"){
					var allChecks = active.find("input[type='radio']:checked");
					for(var j=0;j<allChecks.length;j++){
						fieldValue += ","+allChecks.eq(j).attr("field-key") ;
					}
					
					if(fieldValue.startsWith(",")){
						fieldValue = fieldValue.substring(1);
					}
					
				}
				
				//Label信息
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "label"){
					fieldValue = active.html();
				}
				
				var activeRecord = this.dataSet.getFieldValue(fieldName);
				
				if(Yacon.isEmpty(activeRecord)){
					this.dataSet.setDataSet(fieldName,"");
				}
				
				this.dataSet.getFieldValue(fieldName).setFieldValue("fieldvalue",fieldValue);
						
			}
			
		}
	},
	
	/* 数据展现 - 与Grid 重复 */
	showData: function(){
		
		var record = this.dataSet.getFirstRecord();
		var fieldSize = record.getFieldCount();
		
		for(var i=0;i<fieldSize;i++){
			
			var field = record.getField(i);			
			var fieldName = field.getFieldName();			
			var fieldValue = field.getFieldValue().getFieldValue("fieldoldvalue");	
			
			this.control = "#"+this.elementID +"_window";
			
			var formField = $(this.control+" .lily-field[field-name='"+fieldName+"']");
			var fieldTyp = formField.attr("field-type");
			
			/* 复选框 */
			if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "check"){
				var item = fieldValue.split(",");
				for(var j=0;j<item.length;j++){					
					var itemVal = item[j];				
					formField.find("input[field-key='"+itemVal+"']")
					         .prop("checked","true");				
				}			
			}
			
			/* 单选框 */
			if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "radio"){			
				formField.find("input[field-key='"+fieldValue+"']")
				         .prop("checked","true");							
			}
			
			//Label信息
			if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "label"){
				formField.html(fieldValue);
			}
			
			else{
				$(this.control+" .lily-field[field-name='"+fieldName+"']").val(fieldValue);
				$(this.control+" .lily-fix-field[field-fix-name='"+fieldName+"']").val(fieldValue);
			}
			
		}
	},
	
	/* 点击处理 */
	nodeClick: function(event, treeId, treeNode){
		
		this.resetTree(treeId, treeNode);
		
		Yacon.callBack(this.elementID+"_onclick", [this,this.page]);
		
		var frameID = this.view.frameID;
		
		if(!Yacon.isEmpty(frameID)){	
			
			var frame = this.page.find(frameID);
			frame.clear();
			frame.show();
		}
		
	},
	
	layoutBefore: function(){
		
	},
	
	
	refreshElement: function(){
		
	},
	
	getZtree: function(){
		this.zTree = $.fn.zTree.getZTreeObj(this.treeId);
		return this.zTree;
	},
	
	/* 获取复选节点 */
	getCheckNodes: function(param){
		
		if(Yacon.isEmpty(param)){
			return this.getCheckAllNodes();
		}
		
		else if(param == "leaf"){
			return this.getCheckLeafNodes();
		}
		
		else if(param == "parent"){
			return this.getCheckParentNodes();
		}
		
		else if(Yacon.isNumber(param)){
			return this.getCheckLevelNode(param);
		}
		
		else{
			return this.getCheckAllNodes();
		}
			
	},
	
	getCheckNodesIds: function(param){
		
		var node = this.getCheckNodes(param);
		var nodeIDs = "";
		
		for(var i=0;i<node.length;i++){
			
			nodeIDs += "," + node[i].nodeID;
			
		}
		
		if(!Yacon.isEmpty(nodeIDs)){
			nodeIDs = nodeIDs.substring(1);
		}
		
		return nodeIDs;
		
	},
	
	getCheckNodesCaptions: function(param){
		
		var node = this.getCheckNodes(param);
		var nodeNames = "";
		
		for(var i=0;i<node.length;i++){
			
			nodeNames += "," + node[i].name;
			
		}
		
		if(!Yacon.isEmpty(nodeNames)){
			nodeNames = nodeNames.substring(1);
		}
		
		return nodeNames;
		
	},
	
	getCheckNodesIdAndCaptions: function(param){
		
		var node = this.getCheckNodes(param);
		
		var nodeNames = "";
		
		for(var i=0;i<node.length;i++){
			
			nodeNames += "," + node[i].nodeID +"#"+ node[i].name;
			
		}
		
		if(!Yacon.isEmpty(nodeNames)){
			nodeNames = nodeNames.substring(1);
		}
		
		return nodeNames;
		
	},
	
	getCheckAllNodes: function(){		
		this.getZtree();
		return this.zTree.getCheckedNodes(true);
	},
	
	getUnCheckAllNodes: function(){
		this.getZtree();
		return this.zTree.getCheckedNodes(false);
	},
	
	getCheckLeafNodes: function(){
		
		var checkNodes = this.getCheckAllNodes();
		var retNodes = new Array();
		
		for(var i=0;i<checkNodes.length;i++){
			var activeNode = checkNodes[i];
			
			if(!activeNode.isParent){
				retNodes.add(activeNode);
			}
		}
		
		return retNodes;
		
	},
	
	getCheckParentNodes: function(){
		
		var checkNodes = this.getCheckAllNodes();
		var retNodes = new Array();
		
		for(var i=0;i<checkNodes.length;i++){
			var activeNode = checkNodes[i];
			if(activeNode.isParent){
				retNodes.add(activeNode);
			}
		}
		
		return retNodes;
		
	},
	
	getCheckLevelNode:function(level){
		
		var checkNodes = this.getCheckAllNodes();
		var retNodes = new Array();
		
		for(var i=0;i<checkNodes.length;i++){
			var activeNode = checkNodes[i];
			if(activeNode.level == level){
				retNodes.add(activeNode);
			}
		}
		
		return retNodes;
		
	},
	
	getRadioAllNodes: function(){		
		this.getZtree();
		return this.zTree.getCheckedNodes(true);
	},
	
	getUnRadioAllNodes: function(){
		this.getZtree();
		return this.zTree.getCheckedNodes(false);
	},
	
	/* 获取子节点 */
	getChildNodes: function(){
		return this.treeNode.children;
	},
	
	/* 刷新后 */
	afterRefresh: function(treeId, treeNode){
		
		this.resetTree(treeId, treeNode);
		
		/*if(Yacon.isEmpty(this.getChildNodes()) && treeNode.level != 0){
			this.refreshParent(treeId, treeNode);
		}*/
		
		Yacon.callBack(this.elementID+"_afterRefresh", [this,this.page]);
		
	},
	
	afterRefreshAuto:function(treeId, treeNode){
		
		this.resetTree(treeId, treeNode);
		
		if(Yacon.isEmpty(this.getChildNodes()) && treeNode.level != 0){
			this.refreshParent(treeId, treeNode);
		}
		
		this.startFlag = "past";
		
		Yacon.callBack(this.elementID+"_afterRefresh", [this,this.page]);
	},
	
	/* 刷新前 */
	beforeRefresh: function(treeId,treeNode){
		Yacon.callBack(this.elementID+"_beforeRefresh", [this,this.page]);
	}

};

/* 刷新树 */
function zTreeUrl(treeId, treeNode){	
	var treeObj = $.fn.zTree.getZTreeObj(treeId);	
	var tree = treeObj.setting.lilyTree;	
	return tree.refresh(treeId, treeNode);	
};

/* 删除前 */
function zTreeBeforeRemove(treeId, treeNode){	
	var treeObj = $.fn.zTree.getZTreeObj(treeId);	
	var tree = treeObj.setting.lilyTree;
	tree.deleteNode(treeId, treeNode);	
};

/* 删除后 */
function zTreeAfterRemove(event, treeId, treeNode){
	var treeObj = $.fn.zTree.getZTreeObj(treeId);	
	var tree = treeObj.setting.lilyTree;	
	tree.afterDelete(treeId, treeNode);
};

/* 修改前 */
function  zTreeBeforeRename(treeId, treeNode, newName, isCancel){
	
	/* 添加 */
	if(treeNode.nodeTyp == "add"){
		zTreeAdd(treeId, treeNode, newName, isCancel);
	}
	
	/* 修改 */
	else{
		zTreeEdit(treeId, treeNode, newName, isCancel);
	}
};

/* 树增加 */
function zTreeAdd(treeId, treeNode, newName, isCancel){	
	var treeObj = $.fn.zTree.getZTreeObj(treeId);	
	var tree = treeObj.setting.lilyTree;	
	tree.addNode(treeId, treeNode, newName, isCancel);	
};

/* 树修改 */
function zTreeEdit(treeId, treeNode, newName, isCancel){	
	var treeObj = $.fn.zTree.getZTreeObj(treeId);	
	var tree = treeObj.setting.lilyTree;	
	tree.editNode(treeId, treeNode, newName, isCancel);	
};

/* 修改后 */
function zTreeAfterRename(event, treeId, treeNode, isCancel) {
	
};

/* 修改前处理 */
function zTreeBeforeEditName(treeId, treeNode) {	
	var treeObj = $.fn.zTree.getZTreeObj(treeId);	
	var tree = treeObj.setting.lilyTree;
	return tree.editName(treeId, treeNode);
};

/* 删除展示控制 */
function showRemoveBtn(treeId, treeNode) {
	var treeObj = $.fn.zTree.getZTreeObj(treeId);
	var tree = treeObj.setting.lilyTree;	
	return tree.show(treeId, treeNode,"delete");
};

/* 修改展示控制 */
function showRenameBtn(treeId, treeNode) {	
	var treeObj = $.fn.zTree.getZTreeObj(treeId);
	var tree = treeObj.setting.lilyTree;	
	return tree.show(treeId, treeNode,"edit");
};

/* 自定义添加 */
function addHoverDom(treeId, treeNode) {	
	var treeObj = $.fn.zTree.getZTreeObj(treeId);
	var tree = treeObj.setting.lilyTree;
	return tree.addDom(treeId, treeNode);
};

/* 自定义添加移除 */
function removeHoverDom(treeId, treeNode) {
	$("#addBtn_"+treeNode.tId).unbind().remove();
};

/* 刷新父节点 */
function zTreeRefresh(tree,page){	
	tree.refreshParent(tree.activeTreeId,tree.activeTreeNode);
};

/* 刷新当前节点 */
function zTreeRefreshActive(tree,page){	
	tree.refreshActive(tree.activeTreeId,tree.activeTreeNode);
};

/* 刷新当前节点，顺便父节点处理 */
function zTreeRefreshActiveAuto(tree,page){	
	tree.refreshActiveAuto(tree.activeTreeId,tree.activeTreeNode);
};

/* 树点击回调 */
function zTreeOnClick(event, treeId, treeNode){
	
	var treeObj = $.fn.zTree.getZTreeObj(treeId);
	var tree = treeObj.setting.lilyTree;
	
	tree.nodeClick(event, treeId, treeNode);
	
};

/* 刷新后回调 */
function zTreeAfterRefresh(event, treeId, treeNode, msg){
	var treeObj = $.fn.zTree.getZTreeObj(treeId);
	var tree = treeObj.setting.lilyTree;
	
	if(!Yacon.isEmpty(tree.startFlag) && tree.startFlag == "auto" ){
		tree.afterRefreshAuto(treeId,treeNode);
	}else{
		tree.afterRefresh(treeId,treeNode);
	}
	
};

/* 刷新前回调 */
function zTreeBeforeRefresh(treeId, treeNode){
	var treeObj = $.fn.zTree.getZTreeObj(treeId);
	var tree = treeObj.setting.lilyTree;
	tree.beforeRefresh(treeId,treeNode);
};

function zTreeChange(element){
	if(!Yacon.isEmpty(element.url) && !Yacon.isEmpty(element.frameID)){		
		$("#"+element.frameID).attr("page-path",element.url);			
	}
};;
///<jscompress sourcefile="TTreeView.js" />
Yacon.component.TTreeView = function(conText){
	
	Yacon.apply(this,conText);
	
};

Yacon.component.TTreeView.prototype = {
		
};;
///<jscompress sourcefile="TMultiGrid.js" />
Yacon.component.TMultiGrid = function(conText){
	
	Yacon.apply(this,conText);
	
	if(this.view){
		this.element = this.view;
		this.elementID = this.view.id;
		this.elementType = this.view.type;
	}
	
	this.spinner = new Yacon.widget.TSpin({page:this.page});
	
	this.dataSet = new Yacon.data.DataSet(this.page);
	this.dataSet.elementID = this.elementID;
	this.dataSet.component = this;
	
};

Yacon.component.TMultiGrid.prototype = {
	
	/* 获取HTML */
	getHtml: function(){
		
		var html = "";
		
		html += "<div class='panel row-ht-auto col' role='multigrid' ";		
		html += " lily-id='"+this.elementID+"' lily-type='"+this.elementType+"' ";
		
		html += ">";
		
		/* 标题 */
		this.title = new  Yacon.component.TMultiGridNav({view:this.view.title,parent:this});
		html += this.title.getHtml();
		
		/* 体信息 */
		this.body = new Yacon.component.TMultiGridBody({view:this.view,parent:this});
		html += this.body.getHtml();
		
		/* 菜单部分 */
		if(this.view.title.menu){
			this.menu = new Yacon.widget.TMenu(this.view.title.menu);
			this.menu.parent = this;
			this.menu.dataSet = this.dataSet;
			this.menu.page = this.page;
		}
		
		if(this.view.tableMenu){
			this.tableMenu = new Yacon.widget.TMenu(this.view.tableMenu);
			this.tableMenu.parent = this;
			this.tableMenu.dataSet = this.dataSet;
			this.tableMenu.page = this.page;
			html += this.tableMenu.getRightHtml(this.elementID+"-table-menu");
			
			this.rightMenu = this.tableMenu;
			
		}else{
			
			if(this.view.titleMenu){
				
				this.titleMenu = new Yacon.widget.TMenu(this.view.titleMenu);
				this.titleMenu.parent = this;
				this.titleMenu.dataSet = this.dataSet;
				this.titleMenu.page = this.page;
				html += this.titleMenu.getRightHtml(this.elementID+"-title-menu");
				
				this.rightMenu = this.titleMenu;
			}
			
			if(this.view.dataMenu){
				
				this.dataMenu = new Yacon.widget.TMenu(this.view.dataMenu);
				this.dataMenu.parent = this;
				this.dataMenu.dataSet = this.dataSet;
				this.dataMenu.page = this.page;
				html += this.dataMenu.getRightHtml(this.elementID+"-data-menu");
				
				this.rightMenu = this.dataMenu;
				
			}
			
		}
		
		html += "</div>";
		
		return html;
		
	},
	
	refresh: function(){
		this.dataSet.refresh();
	},
	
	/* 刷新组件 */
	refreshElement: function(){
		
		var html = "";
		
		this.view = this.dataSet.getDataValue();
		
		this.body.refresh();	
		
		this.addEvents();
		
	},
	
	/* 绑定动作 */
	addEvents: function(){
		
		Yacon.callBack(this.elementID+"_beforeEvent", [this,this.page]);
		
		/* 存在菜单 */
		if(!Yacon.isEmpty(this.menu)){		
			this.menu.addTopClick(".panel-heading");
			this.menu.addBottomClick(".panel-heading");	
		}
		
		this.body.addEvents();
		
		if(!Yacon.isEmpty(this.rightMenu)){
			this.rightMenu.addRightClick();
		}
		
		Yacon.callBack(this.elementID+"_afterEvent", [this,this.page]);
		
	},
	
	/* 布局前处理 */
	layoutBefore:function(){
		
		this.spinIn();
		this.spinHidden();
		
	},
	
	/**
	 * 获取所有选中表格
	 */
	getCheckCells: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		this.checkCells = new Array();
		
		var cellObjs = $(search + " .panel-body .table-responsive table.table tbody td.data-field.active");
		var length = cellObjs.length;
		
		for(var i=0;i<length;i++){
			var cellObj = cellObjs.eq(i);
			var activeObj = new Yacon.component.TMultiCell({
				activeCell : cellObj,
				page : this.page,
				parent: this.body,
				search: search
			});
			this.checkCells.add(activeObj);
		}
		
		return this.checkCells;

	},
	
	spinIn: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";

		this.spinner.createSpinner(search);
		
		this.spinner.spinIn(search);
		
	},
	
	spinOut: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		if(!Yacon.isEmpty(this.spinner)){
			this.spinner.spinOut(search);
		}	
		
	},
	
	spinShow: function(){
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";

		if(!Yacon.isEmpty(this.spinner)){
			this.spinner.spinShow(search);
		}
		
	},
	
	spinHidden: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";

		if(!Yacon.isEmpty(this.spinner)){
			this.spinner.spinHidden(search);
		}
		
	}
		
};;
///<jscompress sourcefile="TMultiGridBody.js" />
Yacon.component.TMultiGridBody = function(conText){
	
	Yacon.apply(this,conText);
	
	this.baseCreate();
	
};

Yacon.component.TMultiGridBody.prototype = {
		
	baseCreate: function(){
		
		if(!Yacon.isEmpty(this.view)){
			
			/* 标题固定 */
			this.isTitleFix = this.view.isTitleFix;
			/* 滚动处理 */
			this.isScroll = this.view.isScroll;
			
			this.title = this.view.data.title;
			
			this.body = this.view.data.data;
			
		}
		
	},
	
	/* 获取HTML信息 */	
	getHtml: function(){
		
		var html = "";
		
		html += "<div class='panel-body row-ht-auto col multigrid' style='border-bottom: 1px solid #34495e;'>";
		
		html += this.getFormHtml();
		
		/* 滚动标题 */
		if(!Yacon.isTrue(this.isTitleFix)){			
			html += this.getScrollHtml();			
		}
		
		/* 固定标题 */
		else{			
			html += this.getFixHtml();			
		}
		
		html += "</div>";
			
		return html;
		
	},
	
	/* 固定标题 */
	getFixHtml: function(){
		
		var html = "";
		
		html += "<div class='table-responsive row-ht-auto col' style='min-width:100%;overflow-x: auto;overflow-y:hidden;' ";
		
		if(!Yacon.isEmpty(this.view.tableMenu)){
			html += " data-toggle='context' data-target='#"+this.parent.elementID+"-table-menu' ";
		}
		
		html += ">";	
			
		html += "<div class='row-ht-fix'" ;
		
		if(Yacon.isEmpty(this.view.tableWidth)){
			html +=	" style='width: 100%;' " ;
		}else{
			html +=	" style='width: "+this.view.tableWidth+";' " ;
		}
		
		html +=	" >";
		
		html += "<table class='table clear-margin-bottom fix table-bordered table-striped table-hover' >";
		
		/* 标题 */
		html += this.getHeadHtml();
		
		html += "</table>";
		
		html += "</div>";
		
		html += "<div class='row-ht-auto' ";	
		
		if(Yacon.isEmpty(this.view.tableWidth)){
			html +=	" style='width: 100%;overflow-y:auto;' " ;
		}else{
			html +=	" style='width: "+this.view.tableWidth+";overflow-y:auto;' " ;
		}
		
		html += ">";
		
		html += "<table class='table clear-margin-bottom fix table-bordered table-striped table-hover' >";
		
		/* 数据 */
		html += this.getBodyHtml();
		
		html += "</table>";		
		html += "</div>";
			
		html += "</div>";	
		
		return html;
		
	},
	
	/* 滚动标题 */
	getScrollHtml: function(){
		
		var html = "";
					
		html += "<div class='table-responsive row-ht-auto col' style='min-width:100%;overflow-x: auto;overflow-y:auto;' ";
		
		if(!Yacon.isEmpty(this.view.tableMenu)){
			html += " data-toggle='context' data-target='#"+this.parent.elementID+"-table-menu' ";
		}
		
		html += ">";	
			
		html += "<div class='row-ht-fix'" ;
		
		if(Yacon.isEmpty(this.view.tableWidth)){
			html +=	" style='width: 100%;' " ;
		}else{
			html +=	" style='width: "+this.view.tableWidth+";' " ;
		}
		
		html +=	" >";
		
		html += "<table class='table clear-margin-bottom fix table-bordered table-striped table-hover' >";
		
		/* 标题 */
		html += this.getHeadHtml();
		
		/* 数据 */
		html += this.getBodyHtml();
		
		html += "</table>";
		
		html += "</div>";
			
		html += "</div>";	
		
		return html;
	},
	
	getHeadHtml: function(){
			
		var html = "";
		
		html += "<thead ";
		
		if(Yacon.isEmpty(this.view.tableMenu) && !Yacon.isEmpty(this.parent.titleMenu)){
			html += " data-toggle='context' data-target='#"+this.parent.elementID+"-title-menu' ";
		}
		
		html += ">"
		
		this.finalIdx = 0;	
			
		for(var row=0;row<this.title.length;row++){
			
			html += "<tr>";
			
			for(var col=0;col<this.title[row].length;col++){
				
				var td = this.title[row][col];
				
				if(row == 0){
					this.finalIdx += Yacon.getInt(td.colSpan);
				}
				
				html += "<td colspan='"+td.colSpan+"' rowspan='"+td.rowSpan+"' ";
				html += " fieldName='"+td.fieldName+"' fieldValue='"+td.fieldValue+"' ";
				
				html += " align='center' valign='middle' ";
				
				var style = "";
				
				if(!Yacon.isEmpty(td.fontColor)){
					style = "color:"+td.fontColor+";"
				}
				
				if(!Yacon.isEmpty(td.backColor)){
					style += " background:"+td.backColor+"; ";
				}
				
				if(!Yacon.isEmpty(td.width)){
					style += " width:"+td.width+"; ";
				}
				
				if(!Yacon.isEmpty(td.height)){
					style += " height:"+td.height+"; ";
				}
				
				if(!Yacon.isEmpty(style)){
					html += " style='"+style+"' ";
				}
				
				html += " class='title-field' ";
				
				html += ">";
				
				html += td.fieldValue;
				
				html += "</td>";
				
			}
			
			html += "</tr>";
			
		}
		
		if(Yacon.isTrue(this.isTitleFix)){
			
			html +="<tr class='tmp-table-row'>"
				
			for(var i=0;i<this.finalIdx;i++){
				html += "<td></td>";
			}
				
			html += "</tr>"
		}
		
		html += "</thead>";
		
		return html;
		
	},
	
	getBodyHtml: function(){
		
		var html = "";
		
		html += "<tbody ";
		
		if(Yacon.isEmpty(this.view.tableMenu) && !Yacon.isEmpty(this.view.dataMenu)){
			html += " data-toggle='context' data-target='#"+this.parent.elementID+"-data-menu' ";
		}
		html += ">";
		
		for(var row=0;row<this.body.length;row++){
			
			html += "<tr>";
			
			for(var col=0;col<this.body[row].length;col++){
				
				var td = this.body[row][col];
				
				html += "<td colspan='"+td.colSpan+"' rowspan='"+td.rowSpan+"' ";
				html += " fieldName='"+td.fieldName+"' fieldValue='"+td.fieldValue+"' ";
				html += " align='center' valign='middle' ";
				html += " fieldCol='"+col+"' fieldRow='"+row+"' ";
							
				var style = "";
				
				if(!Yacon.isEmpty(td.fontColor)){
					style = " color:"+td.fontColor+"; "
				}
				
				if(!Yacon.isEmpty(td.backColor)){
					style += " background:"+td.backColor+"; ";
				}
				
				if(!Yacon.isEmpty(style)){
					html += " style='"+style+"' ";
				}
				
				//标题字段处理
				if(td.type == "title"){
					html += " class='title-field' ";
				}else{
					html += " class='data-field' ";
				}
				
				html += ">";
				
				html += td.fieldValue;
				
				html += "</td>";
				
			}
			
			html += "</tr>";
			
		}
		
		html += "</tbody>";
		
		return html;
		
	},
	
	/* 查询部分 */
	getFormHtml: function(){
		
		var html = "";
		
		var formEle = this.view.form;
		
		if(!Yacon.isEmpty(formEle)){
			
			html += "<div class='table-form row-ht-fix' style='margin-bottom:25px;'>";
			
			var findform = new Yacon.widget.TForm({view:formEle,page:this.parent.page,parent:this.parent});		
			this.parent.page.addComponet(findform);		
			this.parent.findform = findform;
			findform.page = this.parent.page;
			
			html += findform.getHtml();
			
			html += "</div>";
			
		}
		
		return html;
		
	},
	
	refresh: function(){
		
		this.view = this.parent.view;
		
		this.baseCreate();
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		
		var html = this.getHeadHtml() + this.getBodyHtml();
		
		$(search+" .panel-body .table-responsive table.table").empty();
		$(search+" .panel-body .table-responsive table.table").append(html);
		
		/* 重新布局 */
		this.parent.page.layoutOuter(search+" .panel-body");
		
	},
	
	/* 绑定动作 */
	addEvents: function(){
		
		if(Yacon.isTrue(this.isTitleFix)){
			this.autoWidth();
		}
		
		self.headTimer = null;
		self.dataTimer = null;
		
		//数据单击事件
		this.addDataClick();
		
		//标题单击事件
		this.addHeadClick();
		
		//数据双击事件
		this.addDataDbClick();
		
		//标题双击事件
		this.addHeadDbClick();
		
	},
	
	autoWidth: function(){
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		
		var TRs = $(search +" .panel-body .table-responsive tbody tr");
		var HR = $(search +" .panel-body .table-responsive thead .tmp-table-row");
		if(TRs.length>0){
			var TR = TRs.eq(0);
			var TDs = TR.find("td");
			var HDs = HR.find("td");
			
			for(var i=0;i<TDs.length;i++){
				
				if(i != (TDs.length-1)){
					TDs.eq(i).css("width",HDs.eq(i).css("width"));
				}		
				
			}
			
		}
		
		$(search +" .panel-body .table-responsive thead .tmp-table-row").remove();
		
	},
	
	addHeadClick: function(){
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		var self = this;
		
		$(search+" .panel-body .table-responsive thead td").unbind("click");
		$(search+" .panel-body .table-responsive thead td").click(function(){
			
			if(!Yacon.isEmpty(self.headTimer)){
				clearTimeout(self.headTimer);
			}
			
			var childSelf = this;
			
			self.headTimer = setTimeout(function(){
				
				var activeCell = new Yacon.component.TMultiCell({
					activeCell : $(childSelf),
					page : self.parent.page,
					parent: self,
					search: search
				});
				
				if(!Yacon.isEmpty(self.parent.view.titleClick)){
					Yacon.callBack(self.parent.view.titleClick, [activeCell,page]);
				}
				
				else if(!Yacon.isEmpty(self.parent.view.tableClick)){
					Yacon.callBack(self.parent.view.tableClick, [activeCell,page]);
				}
				
			},300);
			
		});
		
	},
	
	addDataClick: function(){
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		var self = this;
		
		$(search+" .panel-body .table-responsive tbody td").unbind("click");
		$(search+" .panel-body .table-responsive tbody td").click(function(){
			
			if(!Yacon.isEmpty(self.dataTimer)){
				clearTimeout(self.dataTimer);
			}
			
			var childSelf = this;
			
			self.dataTimer = setTimeout(function(){
				
				self.addModeEvents($(childSelf));	
				
				var activeCell = new Yacon.component.TMultiCell({
					activeCell : $(childSelf),
					page : self.parent.page,
					parent: self,
					search: search
				});
				
				if(!Yacon.isEmpty(self.parent.view.cellClick)){
					Yacon.callBack(self.parent.view.cellClick, [activeCell,page]);
				}
				
				else if(!Yacon.isEmpty(self.parent.view.rowClick)){
					Yacon.callBack(self.parent.view.rowClick, [activeCell,page]);
				}
				
				else if(!Yacon.isEmpty(self.parent.view.colClick)){
					Yacon.callBack(self.parent.view.colClick, [activeCell,page]);
				}
				
				else if(!Yacon.isEmpty(self.parent.view.dataClick)){
					Yacon.callBack(self.parent.view.dataClick, [activeCell,page]);
				}
				
				else if(!Yacon.isEmpty(self.parent.view.tableClick)){
					Yacon.callBack(self.parent.view.tableClick, [activeCell,page]);
				}
				
			},300);
			
		});
		
	},
	
	addHeadDbClick: function(){
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		var self = this;
		
		$(search+" .panel-body .table-responsive thead td").dblclick(function(){
			
			if(!Yacon.isEmpty(self.headTimer)){
				clearTimeout(self.headTimer);
			}
				
			var activeCell = new Yacon.component.TMultiCell({
				activeCell : $(this),
				page : self.parent.page,
				parent: self,
				search: search
			});
			
			if(!Yacon.isEmpty(self.parent.view.titleDbClick)){
				Yacon.callBack(self.parent.view.titleDbClick, [activeCell,page]);
			}
			
			else if(!Yacon.isEmpty(self.parent.view.tableDbClick)){
				Yacon.callBack(self.parent.view.tableDbClick, [activeCell,page]);
			}
				
		});
		
	},
	
	addDataDbClick: function(){
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		var self = this;
		
		$(search+" .panel-body .table-responsive tbody td").dblclick(function(){
			
			if(!Yacon.isEmpty(self.dataTimer)){
				clearTimeout(self.dataTimer);
			}
						
			self.addModeEvents($(this));	
			
			var activeCell = new Yacon.component.TMultiCell({
				activeCell : $(this),
				page : self.parent.page,
				parent: self,
				search: search
			});
			
			if(!Yacon.isEmpty(self.parent.view.cellDbClick)){
				Yacon.callBack(self.parent.view.cellDbClick, [activeCell,page]);
			}
			
			else if(!Yacon.isEmpty(self.parent.view.rowDbClick)){
				Yacon.callBack(self.parent.view.rowDbClick, [activeCell,page]);
			}
			
			else if(!Yacon.isEmpty(self.parent.view.colDbClick)){
				Yacon.callBack(self.parent.view.colDbClick, [activeCell,page]);
			}
			
			else if(!Yacon.isEmpty(self.parent.view.dataDbClick)){
				Yacon.callBack(self.parent.view.dataDbClick, [activeCell,page]);
			}
			
			else if(!Yacon.isEmpty(self.parent.view.tableDbClick)){
				Yacon.callBack(self.parent.view.tableDbClick, [activeCell,page]);
			}
			
		});
		
	},
	
	/* 形式变化 */
	addModeEvents: function(tdObj){

		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		
		var choice = this.parent.view.choice;
		var clickMode = this.parent.view.clickMode;
		
		if(choice == "check"){
					
			if(clickMode == "cell"){
				tdObj.toggleClass("active");
			}
			
			else if(clickMode == "row"){
				
				var row = tdObj.attr("fieldRow");
				$(search+" .panel-body .table-responsive table.table tbody td[fieldRow='"+row+"']").toggleClass("active");
				
			}
			
			else if(clickMode == "col"){
				
				var col = tdObj.attr("fieldCol");
				$(search+" .panel-body .table-responsive table.table tbody td[fieldCol='"+col+"']").toggleClass("active");
				
			}
			
			else if(clickMode == "row-col"){
				var row = tdObj.attr("fieldRow");
				$(search+" .panel-body .table-responsive table.table tbody td[fieldRow='"+row+"']").toggleClass("active");
				var col = tdObj.attr("fieldCol");
				$(search+" .panel-body .table-responsive table.table tbody td[fieldCol='"+col+"']").toggleClass("active");
				tdObj.toggleClass("active");
			}
			
			
		}else{
			$(search+" .panel-body .table-responsive table.table tbody td").removeClass("active");
			
			if(clickMode == "cell"){
				tdObj.toggleClass("active");
			}
			
			else if(clickMode == "row"){
				
				var row = tdObj.attr("fieldRow");
				$(search+" .panel-body .table-responsive table.table tbody td[fieldRow='"+row+"']").toggleClass("active");
				
			}
			
			else if(clickMode == "col"){
				
				var col = tdObj.attr("fieldCol");
				$(search+" .panel-body .table-responsive table.table tbody td[fieldCol='"+col+"']").toggleClass("active");
				
			}
			
			else if(clickMode == "row-col"){
				var row = tdObj.attr("fieldRow");
				$(search+" .panel-body .table-responsive table.table tbody td[fieldRow='"+row+"']").toggleClass("active");
				var col = tdObj.attr("fieldCol");
				$(search+" .panel-body .table-responsive table.table tbody td[fieldCol='"+col+"']").toggleClass("active");
				tdObj.toggleClass("active");
			}
			
		}
	}
		
};;
///<jscompress sourcefile="TMultiGridCell.js" />
Yacon.component.TMultiCell = function(conText){
	
	Yacon.apply(this,conText);
	
	this.baseCreate();
};

Yacon.component.TMultiCell.prototype = {
	
	baseCreate: function(){
		
	},
	
	/* 获取字段标示 */
	getFieldName: function(){
		return this.activeCell.attr("fieldName");
	},
	
	/* 获取字段值 */
	getFieldValue: function(){
		return this.activeCell.attr("fieldValue");
	},
	
	/* 获取列号 */
	getColNo: function(){
		return this.activeCell.attr("fieldCol");
	},
	
	/* 获取行号 */
	getRowNo: function(){
		return this.activeCell.attr("fieldRow");
	},
	
	/* 获取跨行数 */
	getRowSpan: function(){
		return this.activeCell.prop("colspan");
	},
	
	/* 获取跨列数 */
	getColSpan: function(){
		return this.activeCell.prop("rowspan");
	},
	
	/* 获取JQuery活动对象 */
	getActiveCell: function(){
		return this.activeCell;
	},
	
	isTitle: function(){
		if(this.activeCell.hasClass("title-field")){
			return true;
		}else{
			return false;
		}
	},
	
	isData: function(){
		if(this.activeCell.hasClass("data-field")){
			return true;
		}else{
			return false;
		}
	},
	
	/* 获取行表格信息 */
	getRowCells: function(){
		
		this.rows = new Array();
		
		var rowNo = this.getRowNo();
		
		var rowObjs = $(this.search + " .panel-body .table-responsive table.table tbody td[fieldRow='"+rowNo+"']");
		var length = rowObjs.length;
		
		for(var i=0;i<length;i++){
			var rowObj = rowObjs.eq(i);
			var activeObj = new Yacon.component.TMultiCell({
				activeCell : rowObj,
				page : this.page,
				parent: this.parent,
				search: this.search
			});
			this.rows.add(activeObj);
		}
		
		return this.rows;
		
	},
	
	/* 获取行表格信息 */
	getRowDataCells: function(){
		
		this.rows = new Array();
		
		var rowNo = this.getRowNo();
		
		var rowObjs = $(this.search + " .panel-body .table-responsive table.table tbody td.data-field[fieldRow='"+rowNo+"']");
		var length = rowObjs.length;
		
		for(var i=0;i<length;i++){
			var rowObj = rowObjs.eq(i);
			var activeObj = new Yacon.component.TMultiCell({
				activeCell : rowObj,
				page : this.page,
				parent: this.parent,
				search: this.search
			});
			this.rows.add(activeObj);
		}
		
		return this.rows;
		
	},
	
	/* 获取行表格信息 */
	getRowTitleCells: function(){
		
		this.rows = new Array();
		
		var rowNo = this.getRowNo();
		
		var rowObjs = $(this.search + " .panel-body .table-responsive table.table tbody td.title-field[fieldRow='"+rowNo+"']");
		var length = rowObjs.length;
		
		for(var i=0;i<length;i++){
			var rowObj = rowObjs.eq(i);
			var activeObj = new Yacon.component.TMultiCell({
				activeCell : rowObj,
				page : this.page,
				parent: this.parent,
				search: this.search
			});
			this.rows.add(activeObj);
		}
		
		return this.rows;
		
	},
	
	/* 获取列表格信息 */
	getColCells: function(){
		
		this.cols = new Array();
		
		var colNo = this.getColNo();
		
		var colObjs = $(this.search + " .panel-body .table-responsive table.table tbody td[fieldCol='"+colNo+"']");
		var length = colObjs.length;
		
		for(var i=0;i<length;i++){
			var colObj = colObjs.eq(i);
			var activeObj = new Yacon.component.TMultiCell({
				activeCell : colObj,
				page : this.page,
				parent: this.parent,
				search: this.search
			});
			this.cols.add(activeObj);
		}
		
		return this.cols;
		
	},
	
	/* 获取列表格信息 */
	getColTitleCells: function(){
		
		this.cols = new Array();
		
		var colNo = this.getColNo();
		
		var colObjs = $(this.search + " .panel-body .table-responsive table.table tbody td.title-field[fieldCol='"+colNo+"']");
		var length = colObjs.length;
		
		for(var i=0;i<length;i++){
			var colObj = colObjs.eq(i);
			var activeObj = new Yacon.component.TMultiCell({
				activeCell : colObj,
				page : this.page,
				parent: this.parent,
				search: this.search
			});
			this.cols.add(activeObj);
		}
		
		return this.cols;
		
	},
	
	/* 获取列表格信息 */
	getColDataCells: function(){
		
		this.cols = new Array();
		
		var colNo = this.getColNo();
		
		var colObjs = $(this.search + " .panel-body .table-responsive table.table tbody td.data-field[fieldCol='"+colNo+"']");
		var length = colObjs.length;
		
		for(var i=0;i<length;i++){
			var colObj = colObjs.eq(i);
			var activeObj = new Yacon.component.TMultiCell({
				activeCell : colObj,
				page : this.page,
				parent: this.parent,
				search: this.search
			});
			this.cols.add(activeObj);
		}
		
		return this.cols;
		
	}
	
	
};;
///<jscompress sourcefile="TMultiGridNav.js" />
Yacon.component.TMultiGridNav = function(conText){
	
	Yacon.apply(this,conText);
	
	if(!Yacon.isEmpty(this.view)){
		this.name = this.view.name;
		this.ico = this.view.ico;
		this.menu = new Yacon.widget.TMenu(this.view.menu);
	}
	
};

Yacon.component.TMultiGridNav.prototype = {
	
	/* 获取HTML信息 */	
	getHtml: function(){
		
		var html = "";
		
		html += "<div class='panel-heading bk-bg-primary row-ht-fix'>";
		
		html += this.getTitleHtml();
		
		html += '</div>';
		
		return html;
		
	},
	
	/* 获取标题HTML信息 */
	getTitleHtml: function(){
		
		var html = "";
		
		html += "<h5><span class='"+this.ico+"'></span><span class='break'>&nbsp;&nbsp;</span>"+this.name+"</h5>";
		
		if(Yacon.isEmpty(this.parent.view.topbtn)){
			html += this.menu.getTopHtml();
		}else if(this.parent.view.topbtn == "ico"){
			html += this.menu.getTopHtml();
		}else if(this.parent.view.topbtn == "all"){
			html += this.menu.getBottomHtml();
		}else {
			html += this.menu.getTopHtml();
		}
		
		return html;
		
	}	
		
};;
///<jscompress sourcefile="TSqlGrid.js" />
Yacon.component.TSqlGrid = function(conText){
	
	Yacon.apply(this,conText);
	
	if(this.view){
		this.element = this.view;
		this.elementID = this.view.id;
		this.elementType = this.view.type;
	}
	
	this.spinner = new Yacon.widget.TSpin({page:this.page});
	
	this.baseCreate();
	
};

Yacon.component.TSqlGrid.prototype = {
		
	baseCreate: function(){
		
		this.dataSet = new Yacon.data.DataSet(this.page);
		this.dataSet.component = this;
		this.dataSet.elementID = this.elementID;
		this.dataSet.setBody("absolutePage","1");
		this.dataSet.defaultMethod = this.view.grid.excute;
		this.dataSet.refreshMethod = this.view.grid.refresh;

		//字段处理
		this.fields = {};
		var tmpFields = this.view.grid.fields;
		for(var i=0;i<tmpFields.length;i++){
			var tmpField = tmpFields[i];
			this.fields[tmpField.name] = tmpField;		
		};
		
	},	
	
	/* 获取HTML信息 */	
	getHtml: function(){
		
		var html = "";
		
		html += "<div class='panel row-ht-auto col' role='sqlgrid' ";
		
		html += " lily-id='"+this.elementID+"' lily-type='"+this.elementType+"' ";
		
		if(!Yacon.isEmpty(this.element.grid.master)){
			html += " lily-master='"+this.element.grid.master.id+"' ";
		}
		
		html += ">";
		
		/* 标题 */
		this.title = new Yacon.component.TSqlGridTitle(this.view.grid.title);
		this.title.parent = this;
		html += this.title.getHtml();
		
		/* 体信息 */
		this.body = new Yacon.component.TSqlGridBody(this.view);
		this.body.parent = this;
		html += this.body.getHtml();
		
		/* 底部信息 */
		this.foot = new Yacon.component.TSqlGridFoot(this.view.grid.bottom);
		this.foot.parent = this;
		html += this.foot.getHtml();
		
		/* 菜单信息 */
		if(this.view.grid.menu){
			this.menu = new Yacon.widget.TMenu(this.view.grid.menu);
			this.menu.parent = this;
			this.menu.dataSet = this.dataSet;
			this.menu.viewSet = this.viewSet;
			this.menu.page = this.page;
			
			html += this.menu.getHtml();
			
		}
		
		html += "</div>";
		
		return html;
		
	},
	
	/* 点击事件 */
	addEvents: function(){
		
		Yacon.callBack(this.elementID+"_beforeEvent", [this,this.page]);
		
		/* 行点击事件 */
		this.addRowClick();
		
		/* 选中首行 */
		this.clickFirst();
		
		/* 菜单点击 */
		if(!Yacon.isEmpty(this.menu)){		
			this.menu.addTopClick(".panel-heading");
			this.menu.addRightClick();
			this.menu.addBottomClick(".panel-heading");		
		}
		
		/* 底层点击方法 */
		this.foot.addEvent();
		
		Yacon.callBack(this.elementID+"_afterEvent", [this,this.page]);
		
	},
	
	/* 行点击事件 */
	addRowClick: function(){
		
		var self = this;
		
		var search = this.page.element.search +" div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		self.singleTime = null;
		
		$(search + " .panel-body tbody tr").click(function(e){
			
			if(!Yacon.isEmpty(self.singleTime)){
				clearTimeout(self.singleTime);
			}
			
			var childSelf = this;
			
			self.singleTime = setTimeout(function(){
				
				/* 行点击前 */
				if (Yacon.isfireuserEvent(self.elementID+"_onRowClickBefore"))
					Yacon.fireUserEvent(self.elementID+"_onRowClickBefore",[self,self.page]);
				
				$(search + " .panel-body tbody tr").removeClass("active");
				$(childSelf).addClass("active");
				
				self.clickRow();
				
				var foreignGrids = $("div[lily-master='"+self.elementID+"']");
				if(foreignGrids.length>0){
					
					for(var i=0;i<foreignGrids.length;i++){
						var id = foreignGrids.eq(i).attr("lily-id");
						var detailGrid = self.page.find(id);
						detailGrid.getDataSet();
						detailGrid.dataSet.refresh();
					}
					
				}
				
				/* 行点击后 */
				if (Yacon.isfireuserEvent(self.elementID+"_onRowClickAfter"))
					Yacon.fireUserEvent(self.elementID+"_onRowClickAfter",[self,self.page]);
				
			},300);

					
		});
		
		$(search + " .panel-body tbody tr").dblclick(function(e){
			
			if(!Yacon.isEmpty(self.singleTime)){
				clearTimeout(self.singleTime);
			}
			
			/* 行双击前 */
			if (Yacon.isfireuserEvent(self.elementID+"_onRowDbClickBefore"))
				Yacon.fireUserEvent(self.elementID+"_onRowDbClickBefore",[self,self.page]);
			
			$(search + " .panel-body tbody tr").removeClass("active");
			$(this).addClass("active");
			
			self.clickRow();
			
			var foreignGrids = $("div[lily-master='"+self.elementID+"']");
			if(foreignGrids.length>0){
				
				for(var i=0;i<foreignGrids.length;i++){
					var id = foreignGrids.eq(i).attr("lily-id");
					var detailGrid = self.page.find(id);
					detailGrid.getDataSet();
					detailGrid.dataSet.refresh();
				}
				
			}
			
			var detail = self.view.detail;
			
			/* 弹窗处理 */
			if(!Yacon.isEmpty(self.view.detail) && !Yacon.isEmpty(self.view.detail.path)){
				
				var width = detail.width;
				var height = detail.height;
				var path =  detail.path;
				
				self.dataSet.setAction("type","0");
				
				path = Yacon.addUrlParam("state", "past", path);
				
				Yacon.showModal({
					heigth : height ,
					width : width ,
					url : path ,
					dataSet : self.dataSet
				});
				
			}
			
			/* 行双击后 */
			if (Yacon.isfireuserEvent(self.elementID+"_onRowDbClickAfter"))
				Yacon.fireUserEvent(self.elementID+"_onRowDbClickAfter",[self,self.page]);

		});	
		
		/* 复选框事件 */
		$(search + " input.check-all-field").click(function(e){
			 
			 if($(this).is(':checked')){
				 $(search + " input.check-field").prop("checked",$(this).is(':checked'));
			 }else{
				 $(search + " input.check-field").prop("checked",$(this).is(':checked'));
			 }		 
			 
		});
		
		
	},
	
	/* 选中首行 */
	clickFirst: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		var active = $(search+" .panel-body tbody tr.active");
		
		if(active.length <= 0){
			
			$(search+" .panel-body tbody tr").removeClass("active");
			
			var trs = $(search+" .panel-body tbody tr");
			
			if(trs.length>0){
				trs.eq(0).click();
			}else{
				
				var foreignGrids = $("div[lily-master='"+this.elementID+"']");
				if(foreignGrids.length>0){
					
					for(var i=0;i<foreignGrids.length;i++){
						var id = foreignGrids.eq(i).attr("lily-id");
						var detailGrid = this.page.find(id);
						detailGrid.body.reset();
						detailGrid.foot.reset();
					}
					
				}
				
			}
		}
		
		this.clickRow();
		
	},
	
	/* 行点击 */
	clickRow: function(){		
		this.dataSet.clearDataSet();	
		this.dataSet.getDataSet();	
	},
	
	instData: function(){
		
		var typ = this.dataSet.getAction("type");		

		if(typ == "1"){
			this.insertDataSet();
		}
		
		else if(typ == "2"){
			this.editDataSet();
		}
		
		else if(typ == "3"){
			
		}
		
		return true;

	},
	
	insertDataSet: function(){
		
		if(Yacon.isEmpty(this.view.detail) || Yacon.isEmpty(this.view.detail.path)){			
			this.clickRow();		
			return;			
		}
			
		var alls;
		
		this.control = "#"+this.elementID+"_window ";
		
		if(this.control){			
			alls = $(this.control+" .lily-field");		
		}else{
			alls = $(".lily-field");
		}
		
		if(alls){
			
			var size = alls.length;	
			this.dataSet.getFirstRecord();	
			
			for(var i=0;i<size;i++){
			
				var active = alls.eq(i);
				var fieldName = active.attr("field-name");
				var fieldValue = active.val();
				
				if(Yacon.isNull(fieldValue)){
					fieldValue = "";
				}
				
				//复选框
				var fieldTyp = active.attr("field-type");
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "check"){
					var allChecks = active.find("input[type='checkbox']:checked");
					for(var j=0;j<allChecks.length;j++){
						fieldValue += ","+allChecks.eq(j).attr("field-key") ;
					}
					
					if(fieldValue.startsWith(",")){
						fieldValue = fieldValue.substring(1);
					}
					
				}
				
				//单选框
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "radio"){
					var allChecks = active.find("input[type='radio']:checked");
					for(var j=0;j<allChecks.length;j++){
						fieldValue += ","+allChecks.eq(j).attr("field-key") ;
					}
					
					if(fieldValue.startsWith(",")){
						fieldValue = fieldValue.substring(1);
					}
					
				}
				
				//Label信息
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "label"){
					fieldValue = active.html();
				}
				
				var fieldOldValue = fieldValue;
				
				this.dataSet.setDataSet(fieldName,fieldValue,fieldOldValue);
				
			}
			
		}
		
	},
	
	editDataSet: function(){
		
		if(Yacon.isEmpty(this.view.detail) || Yacon.isEmpty(this.view.detail.path)){		
			this.clickRow();		
			return;		
		}
		
		var alls;
		
		if(this.control){			
			alls = $(this.control+" .lily-field");		
		}else{
			alls = $(".lily-field");
		}
		
		if(alls){
			
			var size = alls.length;	
			this.dataSet.getFirstRecord();	
			
			for(var i=0;i<size;i++){
			
				var active = alls.eq(i);
				var fieldName = active.attr("field-name");
				var fieldValue = active.val();
				
				if(Yacon.isNull(fieldValue)){
					fieldValue = "";
				}
				
				//复选框
				var fieldTyp = active.attr("field-type");
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "check"){
					var allChecks = active.find("input[type='checkbox']:checked");
					
					for(var j=0;j<allChecks.length;j++){
						fieldValue += ","+allChecks.eq(j).attr("field-key") ;
					}
					
					if(fieldValue.startsWith(",")){
						fieldValue = fieldValue.substring(1);
					}
				}
				
				//单选框
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "radio"){
					var allChecks = active.find("input[type='radio']:checked");
					for(var j=0;j<allChecks.length;j++){
						fieldValue += ","+allChecks.eq(j).attr("field-key") ;
					}
					
					if(fieldValue.startsWith(",")){
						fieldValue = fieldValue.substring(1);
					}
					
				}
				
				//Label信息
				if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "label"){
					fieldValue = active.html();
				}
				
				var activeRecord = this.dataSet.getFieldValue(fieldName);
				
				if(Yacon.isEmpty(activeRecord)){
					this.dataSet.setDataSet(fieldName,"");
				}
				
				this.dataSet.getFieldValue(fieldName).setFieldValue("fieldvalue",fieldValue);
						
			}
			
		}
	},
	
	showData: function(){
		
		var record = this.dataSet.getFirstRecord();
		var fieldSize = record.getFieldCount();
		
		for(var i=0;i<fieldSize;i++){
			
			var field = record.getField(i);			
			var fieldName = field.getFieldName();			
			var fieldValue = field.getFieldValue().getFieldValue("fieldoldvalue");	
			
			this.control = "#"+this.elementID +"_window";
			
			var formField = $(this.control+" .lily-field[field-name='"+fieldName+"']");
			var fieldTyp = formField.attr("field-type");
			
			/* 复选框 */
			if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "check"){
				var item = fieldValue.split(",");
				for(var j=0;j<item.length;j++){					
					var itemVal = item[j];				
					formField.find("input[field-key='"+itemVal+"']")
					         .prop("checked","true");				
				}			
			}
			
			/* 单选框 */
			if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "radio"){			
				formField.find("input[field-key='"+fieldValue+"']")
				         .prop("checked","true");							
			}
			
			//Label信息
			if(!Yacon.isEmpty(fieldTyp) && fieldTyp == "label"){			
				formField.html(fieldValue);
			}
			
			else{
				$(this.control+" .lily-field[field-name='"+fieldName+"']").val(fieldValue);
				$(this.control+" .lily-fix-field[field-fix-name='"+fieldName+"']").val(fieldValue);
			}
			
		}
	},
	
	/* 创建新行 */
	createRow: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		var html = "<tr class='active active-row add-row' style='height:31px;'>";
		
		var idx = 0;
			
		var head = $(search+" thead tr th");
		var grid = $(search);
		
		if(this.view.grid.choice=="check"){
			html += "<td style='width:25px;'>";		
			html += "<label class='checkbox-inline'>";
			html += "<input type='checkbox' style='position:static;' class='check-field' id='inlineCheckbox1' value='option1'>&nbsp;</input>";
			html += "</label>";		
			html += "</td>";
			idx++;
		}
		
		for(;idx<=head.length-1;idx++){
			
			var activeHead = head.eq(idx);
			
			var fieldName = activeHead.attr("field_name");	
			var fieldTyp = activeHead.attr("field_typ");
			var fieldExp = activeHead.attr("field_exp");
			/* 9px 内外补 */			
			var width = activeHead.css("width");
			var display = activeHead.css("display");
					
			if(display == "none"){			
				html += "<td style='width:"+width+";display:none;' field_name='"+fieldName+"' field_text='' field_val='' ";	
				
				html += " field_typ='"+fieldTyp+"' ";
				html += " field_exp='"+fieldExp+"' ";
				html += " field_old_val='' ";
				
				html += "></td>";
				
			}else{
				width = (Yacon.getPx(width)-9) + "px";
				
				html += "<td ";
				
				html += " style='width:"+width+"' "
				
				html += " field_name='"+fieldName+"' field_text='' field_val='' ";
				
				html += " field_typ='"+fieldTyp+"' ";
				html += " field_exp='"+fieldExp+"' ";
				html += " field_old_val='' ";
				
				html += ">"
					
				html += "</td>";	
				
			}

			
		}
		
		html += "</tr>";
		
		var active = $(search+" tbody tr.active");
		
		if(active.length > 0){
			active.removeClass("active");
			active.after(html);
		}else{
			$(search +" tbody").append(html);
		}
		
		
	},
	
	createRowEvent: function(dataSet){
		
		var self = this;
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		$(search + " .panel-body tbody tr").unbind("click");
		
		$(search + " tbody tr.active td").click(function(){
			
			var info = $(this).text();
			
			$(this).empty();
			
			var fieldName = $(this).attr("field_name");
			var fieldTyp = $(this).attr("field_typ");
			var fieldExp = $(this).attr("field_exp");
			var width = (Yacon.getPx($(this).css("width")) - 9) + "px";
			
			var html = "";
			
			if(fieldTyp == "TEXT"){
				
				html += "<input style='width:"+width+";' id='"+fieldName+"' name='"+fieldName+"' type='text' value='"+info+"'/>";
				
			}
			
			else if(fieldTyp == "NUMBER"){
				html += "<input style='width:"+width+";' id='"+fieldName+"' name='"+fieldName+"' type='number' value='"+info+"'/>";
			}
			
			else if(fieldTyp == "DROP_SELECT"){
				
				html += "<select style='width:"+width+";' id='"+fieldName+"' name='"+fieldName+"' value=''>";
				
				html += "<option value=''></option>";
				
				if(!Yacon.isEmpty(fieldExp)){
					var activeEnum = self.view.grid.enums[fieldExp];		
					if(!Yacon.isEmpty(activeEnum)){
						
						for(var i=0;i<activeEnum.length;i++){
							
							html += "<option value='"+activeEnum[i].key+"'>"+activeEnum[i].value+"</option>";
							
						}
						
					}	
				}
				
				html += "</select>";
				
				/* 下拉失去点击事件 */
				$(this).unbind("click");

			}
			
			$(this).append(html);
			
			$(this).find("input").focus();		
			$(this).find("input").unbind("blur");			
			$(this).find("input").blur(function(){
				
				var value = $(this).val();
				var parent = $(this).parent();
				
				parent.empty();
				parent.append(value);
				
				parent.attr("field_text",value);
				parent.attr("field_val",value);
				
			});
			
			/*$(this).find("select").focus();*/
			$(this).find("select").unbind("change");	
			$(this).find("select").change(function(){
				
				var value = $(this).val();
				var parent = $(this).parent();
				
				parent.attr("field_text",value);
				parent.attr("field_val",value);
				
			});
			
			
		});
		
	},
	
	/* 修改行 */
	editRow: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		var active = $(search+" tbody tr.active");			
		active.addClass("active-row");
		active.addClass("edit-row");
		
		/* 原始值赋值 */
		var TDs = active.find("td");
		var TDSize = TDs.length;
		for(var i=0;i<TDSize;i++){
			var activeTD = TDs.eq(i);
			var value = activeTD.attr("field_val");
			if(value != undefined){
				activeTD.attr("field_old_val",value);
			}	
		}
		
	},
	
	editRowEvent: function(dataSet){
		
		var self = this;
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		$(search + " .panel-body tbody tr").unbind("click");
		
		$(search + " tbody tr.active td").click(function(){
			
			var fieldName = $(this).attr("field_name");
			
			if(self.fields[fieldName].isEdit){
				
				var info = $(this).text();
				
				$(this).empty();
				
				
				var fieldTyp = $(this).attr("field_typ");
				var fieldExp = $(this).attr("field_exp");
				var width = (Yacon.getPx($(this).css("width")) - 9) + "px";
				
				var html = "";
				
				if(fieldTyp == "TEXT"){
					
					html += "<input style='width:"+width+";' id='"+fieldName+"' name='"+fieldName+"' type='text' value='"+info+"'/>";
					
				}
				
				else if(fieldTyp == "NUMBER"){
					html += "<input style='width:"+width+";' id='"+fieldName+"' name='"+fieldName+"' type='number' value='"+info+"'/>";
				}
				
				else if(fieldTyp == "DROP_SELECT"){
					
					html += "<select style='width:"+width+";' id='"+fieldName+"' name='"+fieldName+"' value=''>";
					
					html += "<option value=''></option>";
					
					if(!Yacon.isEmpty(fieldExp)){
						var activeEnum = self.view.grid.enums[fieldExp];		
						if(!Yacon.isEmpty(activeEnum)){
							
							for(var i=0;i<activeEnum.length;i++){
								
								html += "<option value='"+activeEnum[i].key+"'>"+activeEnum[i].value+"</option>";
								
							}
							
						}	
					}
					
					html += "</select>";
					
					/* 下拉失去点击事件 */
					$(this).unbind("click");

				}
				
				$(this).append(html);
				
				$(this).find("input").focus();		
				$(this).find("input").unbind("blur");			
				$(this).find("input").blur(function(){
					
					var value = $(this).val();
					var parent = $(this).parent();
					
					parent.empty();
					parent.append(value);
					
					parent.attr("field_text",value);
					parent.attr("field_val",value);
					
				});
				
				/*$(this).find("select").focus();*/
				$(this).find("select").unbind("change");	
				$(this).find("select").change(function(){
					
					var value = $(this).val();
					var parent = $(this).parent();
					
					parent.attr("field_text",value);
					parent.attr("field_val",value);
					
				});
				
			};
			
		});
		
	},
	
	refreshElement: function(){
		
		var html = "";
		
		this.view = this.dataSet.getDataValue();	
		
		this.body.refresh();	
		this.foot.refresh();
		
		this.addEvents();
		
	},
	
	refresh: function(){
		this.dataSet.refresh();		
	},
	
	getDataSet: function(){
		this.dataSet.getDataSet("flat");
		this.dataSet.next();
		return this;
	},
	
	getCheckDataSet: function(){
		this.dataSet.getDataSet("check");
		this.dataSet.dataset.beforeFirst();
		return this;
	},
	
	getFieldValue: function(fieldName){
		return this.dataSet.getDataSetValue(fieldName);
	},
	
	next: function(){
		return this.dataSet.next();
	},
	
	getRecordCount: function(){
		return this.dataSet.getDataSetCount();
	},
	
	/* 后续布局处理 */
	layoutBefore:function(){
		
		this.body.refresh();
		
		this.spinIn();
		
		this.spinHidden();
		
	},
	
	spinIn: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";

		this.spinner.createSpinner(search);
		
		this.spinner.spinIn(search);
		
	},
	
	spinOut: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";
		
		if(!Yacon.isEmpty(this.spinner)){
			this.spinner.spinOut(search);
		}	
		
	},
	
	spinShow: function(){
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";

		if(!Yacon.isEmpty(this.spinner)){
			this.spinner.spinShow(search);
		}
		
	},
	
	spinHidden: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";

		if(!Yacon.isEmpty(this.spinner)){
			this.spinner.spinHidden(search);
		}
		
	}
	
	
		
};;
///<jscompress sourcefile="TSqlGridBody.js" />
Yacon.component.TSqlGridBody = function(element){
	this.element = element;	
	
	if(this.element.width){
		this.element.width = this.element.width - 2;
	}
	
	this.isXScoll = false;
	
};

Yacon.component.TSqlGridBody.prototype = {
	
	getHtml: function(){
		
		var html = "";
		
		html += "<div class='panel-body row-ht-auto col' style='padding-bottom:25px;'>";	
		
		//查询部分处理
		html += this.getFormHtml();
				
		html += "<div class='table-responsive row-ht-auto col' style='width:100%;overflow-x: auto;overflow-y:hidden; border:1px solid #DDDDDD'>";
		
		html += '</div>';		
		html += '</div>';
		
		return html;
		
	},
	
	/* 标题部分HTML */
	getTitleHtml: function(){
		
		var html = "";
		
		html += "<div class='row-ht-fix table-title' style='width: "+this.element.width+"px;background: rgba(52, 73, 94, 0.4) none repeat scroll 0 0;'>";		
		html += "<table class='table clear-margin-bottom fix table-bordered' style='table-layout:fixed;word-break:break-all;' >";		
		html += "<thead>";		
		html += "<tr>";
		
		var choice = this.element.grid.choice;
		if(choice == "flat"){
			
		}else{
			html += "<th style='width:25px;'>";		
			html += "<label class='checkbox-inline'>";
			html += "<input class='check-all-field' style='position:static;' type='checkbox' id='inlineCheckbox1' value='option1'>&nbsp;</input>";
			html += "</label>";		
			html += "</th>";
		}
		
		var alls = this.element.grid.fields;
		var all_size = alls.length;
		for(var i=0;i<all_size;i++){
			html += this.getFieldHtml(alls[i]);
		}
		
		html += "</tr>";
		html += "</thead>";
		html += "</table>";	
		html += "</div>";
		
		return html;
	},
	
	/* 获取字段HTML信息 */
	getFieldHtml: function(field){
		
		var html = "";
		
		var style = "";
		if(!field.isFinal){
			style += "width:"+field.width+"px;";
		}
			
		if(!field.isShow){
			style += "display:none;";
		}
		
		style += "word-wrap:break-word;";
		
		html += "<th style='"+style+"' field_name='"+field.name+"' field_text='"+field.text+"' field_val='"+field.value+"' ";
		
		html += " field_exp='"+field.dropexp+"' field_typ='"+field.type+"' ";
		
		html += ">";
		
		html += field.text;
		
		html += "</th>";
		
		return html;
	},
	
	/* 获取体部分HTML */
	getBodyHtml: function(){
		
		var html = "";
		
		html += "<div class='row-ht-auto table-body' style='width: "+this.element.width+"px;overflow-y:auto;' ";
		
		if(this.element.grid.menu){
			if(this.element.grid.menu.type == "right"){
				html += " data-toggle='context' data-target='#"+this.element.id+"-menu' ";
			}
		}
		
		html += ">";
		
		html += "<table class='table clear-margin-bottom table-striped table-hover table-bordered' style='table-layout:fixed;word-break:break-all;' >";
		html += "<tbody>";
		
		html += this.getDataHtml();
		
		html += "</tbody>";
		html += "</table>";
		
		if(this.isXScoll){
			html += "<div style='height:15px'></div>";
		}
		
		html += "</div>";
		
		return html;
		
	},
	
	/* 数据部分HTML */
	getDataHtml: function(){
		var html = "";
		
		var rowDatas = this.element.data;		
		var rowSize = rowDatas.length;
		
		for(var i=0;i<rowSize;i++){
			
			html += "<tr>";
			
			var choice = this.element.grid.choice;
			if(choice == "flat"){
				
			}else{
				html += "<td style='width:25px;word-wrap:break-word;'>";		
				html += "<label class='checkbox-inline'>";
				html += "<input type='checkbox' style='position:static;' class='check-field' id='inlineCheckbox1' value='option1'>&nbsp;</input>";
				html += "</label>";		
				html += "</td>";
			}
			
			var colDatas = rowDatas[i];
			var colSize = colDatas.length;
			
			for(var j=0;j<colSize;j++){
				
				if(i == 0){
					
					html += this.getDataFieldHtml(colDatas[j], this.element.grid.fields[j],true);
										
				}
				else{
				    html += this.getDataFieldHtml(colDatas[j], this.element.grid.fields[j],false);
				}
				
			}
			
			html += "</tr>";
			
		}
			
		return html;
	},
	
	/* 获取数据HTML部分 */
	getDataFieldHtml: function(data,field,isWidth){
		
		var html = "";
		
		var style = "";
				
		if(!field.isShow){
			style += "display:none;";
		}
		
		style += "word-wrap:break-word;";
		
		if(isWidth){			
			if(!field.isFinal){
				style += "width:"+field.width+"px;";
			}
		}
			
		if(style == ""){
			html += "<td ";
		}else{
			html += "<td style='"+style+"' ";
		}
		
		html += " field_name='"+data.name+"' field_text='"+data.text+"' field_val='"+data.value+"' ";
		
		html += " field_typ='"+field.type+"' field_exp='"+field.dropexp+"' ";
		
		html += ">";
		
		html += data.text;
		
		html += "</td>";
			
		return html;
		
	},
	
	getFormHtml: function(){
		
		var html = "";
		
		var formEle = this.element.grid.form;
		
		if(!Yacon.isEmpty(formEle)){
			
			html += "<div class='table-form row-ht-fix'>";
			
			var findform = new Yacon.widget.TForm({view:formEle,page:this.parent.page,parent:this.parent});		
			this.parent.page.addComponet(findform);		
			this.parent.findform = findform;
			html += findform.getHtml();
			
			html += "</div>";
		}
		
		return html;
		
	},
	
	/* 自动宽度调整 */
	autoWidth: function(){
		
		this.isCheck = false;
		if(this.parent.view.grid.choice == "check"){
			this.isCheck = true;
		}
			
		var winWidth = this.element.width;
		
		winWidth = this.getNumber(winWidth);
		
		var show_fields = new Array();
		
		/* 处理需要展示信息 */
		var alls = this.element.grid.fields;
		var all_size = alls.length;
		for(var i=0;i<all_size;i++){
			if(alls[i].isShow){
				show_fields.add(alls[i]);
			}
		}
		
		/*二次遍历，预处理信息*/
		var show_size = show_fields.length;
		var fixLength = 0;
		var totalLength = 0;
		var autoSize = 0;
		for(var i=0;i<show_size;i++){
						
			show_fields[i].width = this.getNumber(show_fields[i].width);
					
			var active_width = show_fields[i].width;
			
			totalLength += active_width;
			
			if(active_width == 120){
				autoSize ++;
			}
			else{
				fixLength += active_width;
			}

			if(i == (show_size-1)){
				show_fields[i].isFinal = true;
			}else{
				show_fields[i].isFinal = false;
			}
				
		}
		
		var totalAllLength = totalLength;
		if(this.isCheck){
			totalAllLength += 25;
			fixLength += 25;
		}
		
		/* 三次遍历，最终结果 */
		if(totalAllLength >= winWidth){
			this.element.width = totalAllLength;
			this.isXScoll = true;
		}else{
			
			var autoLength = (winWidth - fixLength) / autoSize;
			for(var i=0;i<show_size;i++){
				
				var active_width = show_fields[i].width;
				if(active_width == 120){
					show_fields[i].width = autoLength;
				}
				
			}
			
		}
		
		
	},
	
	/* 根据宽度值 - 获取数值 */
	getNumber: function(widthStr){
		
		widthStr = widthStr + "";
		
		widthStr = widthStr.trim();
		
		if(widthStr.endWith("px")){
			return parseFloat(widthStr.substring(0,widthStr.length-2));
		}
		
		else if(widthStr.endWith("%")){			
			var num = parseFloat(widthStr.substring(0,widthStr.length-1)) / 100;		
			return Yacon.getWidthNumber(this.element.width) * num;
		}
		
		else{			
			return parseFloat(widthStr);		
		}
		
	},
	
	refresh: function(){
			
		delete this.element;
		
		this.element = this.parent.view;
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		
		var width = $(search+" .panel-body .table-responsive").width();
		
		this.element.width = width;
		
		this.autoWidth();
		
		var html = this.getTitleHtml() + this.getBodyHtml();
		
		$(search+" .panel-body .table-responsive").empty();
		$(search+" .panel-body .table-responsive").append(html);
		
		/* 重新布局 */
		this.parent.page.layoutOuter(search+" .panel-body");
		
	},
	
	reset: function(){
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		$(search+" .panel-body .table-responsive tbody").empty();
		
	}
		
};;
///<jscompress sourcefile="TSqlGridFoot.js" />
Yacon.component.TSqlGridFoot = function(element){
	this.element = element;
	this.page = this.element.page;
	this.pageNo = this.element.pageNo;
	this.recordNo = this.element.recordNo;
};

Yacon.component.TSqlGridFoot.prototype = {

	/* 获取底部HTML信息 */	
	getHtml: function(){
		
		var html = "";
		
		html += "<div class='panel-footer bk-bg-primary fix row-ht-fix' page='"+this.element.page+"' page-no='"+this.element.pageNo+"' record-no='"+this.element.recordNo+"'>";		
		html += "<div class='row'>";
		
		html += "<div class='col-md-3 col-md-offset-5'>";
		html += "<a class='step-backward' href='javascript:void(0);'><span class='glyphicon glyphicon-step-backward'></span></a>";
		html += "<input class='page-no-input' type='text' value='"+this.element.page+"/"+this.element.pageNo+"'/>";
		html += "<a class='step-forward' href='javascript:void(0);'><span class='glyphicon glyphicon-step-forward'></span></a>";
		html += "</div>";
		
		html += "<div class='record-no-div col-md-2 col-md-offset-2'>";
		html += "共计 : "+this.element.recordNo+" 条记录";
		html += "</div>";
		
		html += "</div>";
		html += '</div>';
			
		return html;
		
	},
	
	refresh: function(){
		
		this.element = this.parent.view.grid.bottom;
		this.page = this.element.page;
		this.pageNo = this.element.pageNo;
		this.recordNo = this.element.recordNo;
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		
		$(search+" .panel-footer").attr("page",this.element.page);
		$(search+" .panel-footer").attr("page-no",this.element.pageNo);
		$(search+" .panel-footer").attr("record-no",this.element.recordNo);
		
		$(search+" .page-no-input").val(this.element.page+"/"+this.element.pageNo);
		$(search+" .record-no-div").html("共计 : "+this.element.recordNo+" 条记录");
		
	},
	
	/**
	 * 添加动作
	 */
	addEvent: function(){
		
		var parent = this.parent;
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		var self = this;
		
		/* 上一页 */
		$(search+" .panel-footer .step-backward").unbind("click");
		$(search+" .panel-footer .step-backward").click(function(){
						
			var pageBefore = self.page;
			if(pageBefore != 1){
				pageBefore -- ;
			}
			
			$(search+" .panel-footer").attr("page",pageBefore);
			
			self.parent.dataSet.setBody("absolutePage",pageBefore);		
			self.parent.dataSet.refresh();
			
		});
		
		/* 下一页 */
		$(search+" .panel-footer .step-forward").unbind("click");
		$(search+" .panel-footer .step-forward").click(function(){		
					
			var pageAfter = self.page;
			if(pageAfter != self.pageNo){
				pageAfter ++ ;
			}
			
			$(search+" .panel-footer").attr("page",pageAfter);
			
			self.parent.dataSet.setBody("absolutePage",pageAfter);		
			self.parent.dataSet.refresh();
		});
		
		/* 键盘事件 */
		$(search+" .page-no-input").unbind("keypress");
		$(search+" .page-no-input").keypress(function(e){
			 if(e.which == 13) { 
				 	 
				var val = $(this).val();  
				
				if(val <= 0){
					val = 1;
				}
				
				if(val > self.pageNo){
					val = self.pageNo;
				}
				
				$(search+" .panel-footer").attr("page",val);
				
				$(this).blur();
				
				self.parent.dataSet.setBody("absolutePage",val);			
				self.parent.dataSet.refresh();	
				
			 }  
		});
		
	},
	
	reset: function(){
		
		var search = this.parent.page.element.search + " div[lily-id='"+this.parent.elementID+"'][lily-type='"+this.parent.elementType+"']";
		
		$(search+" .panel-footer").attr("page","1");
		$(search+" .panel-footer").attr("page-no","1");
		$(search+" .panel-footer").attr("record-no","0");
		
		$(search+" .page-no-input").val(1+"/"+1);
		$(search+" .record-no-div").html("共计 : "+0+" 条记录");
		
	}
		
};;
///<jscompress sourcefile="TSqlGridForm.js" />
Yacon.component.TSqlGridForm = function(element){
	this.element = element;
};

Yacon.component.TSqlGridForm.prototype = {
		
};;
///<jscompress sourcefile="TSqlGridTitle.js" />
Yacon.component.TSqlGridTitle = function(element){
	this.element = element;
	
	this.name = element.name;
	this.ico = element.ico;
	this.menu = new Yacon.widget.TMenu(element.menu);
	
};

Yacon.component.TSqlGridTitle.prototype = {
	
	/* 获取HTML信息 */	
	getHtml: function(){
		
		var html = "";
		
		html += "<div class='panel-heading bk-bg-primary row-ht-fix'>";
		
		html += this.getTitleHtml();
		
		html += '</div>';
		
		return html;
		
	},
	
	/* 获取标题HTML信息 */
	getTitleHtml: function(){
		
		var html = "";
		
		html += "<h5><span class='"+this.ico+"'></span><span class='break'>&nbsp;&nbsp;</span>"+this.name+"</h5>";	
		
		if(Yacon.isEmpty(this.parent.view.grid.topbtn)){
			html += this.menu.getTopHtml();
		}else if(this.parent.view.grid.topbtn == "ico"){
			html += this.menu.getTopHtml();
		}else if(this.parent.view.grid.topbtn == "all"){
			html += this.menu.getBottomHtml();
		}else {
			html += this.menu.getTopHtml();
		}
		
		return html;
		
	}
	
};;
///<jscompress sourcefile="ECharts.js" />
Yacon.component.ECharts = function(conText){
	
	Yacon.apply(this,conText);
	
	if(this.view){
		this.element = this.view;
		this.elementID = this.view.id;
		this.elementType = this.view.type;
	}
	
	this.dataSet = new Yacon.data.DataSet(this.page);
	this.dataSet.component = this;
	this.dataSet.elementID = this.elementID;
	this.dataSet.refreshMethod = this.view.refresh;
	
};

Yacon.component.ECharts.prototype = {
	
	getHtml: function(){
		
		var html = "";
		
		html += "<div class='row-ht-auto' style='width:100%;height:100%' ";		
		html += " lily-id='"+this.elementID+"' lily-type='"+this.elementType+"' ";	
		html += " >";
		
		html += "<div id='"+this.elementID+"' style='width:100%;height:100%'></div>";
		
		html += "</div>";
		
		return html;
		
	},
	
	addEvents: function(){
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";		
		this.charts = echarts.init(document.getElementById(this.elementID));  
		this.charts.setOption(this.view.option); 
		
	},
	
	spinShow: function(){
	
	},
	
	spinHidden: function(){
		
	
	},
	
	refreshElement: function(){
		
		var html = "";
		
		this.view = this.dataSet.getDataValue();
		
		var search = this.page.element.search + " div[lily-id='"+this.elementID+"'][lily-type='"+this.elementType+"']";		

		$(search).empty();
		
		$(search).append("<div id='"+this.elementID+"' style='width:100%;height:100%'></div>");
		
		this.charts = echarts.init(document.getElementById(this.elementID));  
		
		this.charts.setOption(this.view.option); 
		
	},
	
	refresh: function(){
		this.dataSet.refresh();
	},
	
	layoutBefore: function(){
		
	}
		
};;
